修改获取version文件超时时间

This commit is contained in:
whyour 2022-10-25 23:52:30 +08:00
parent 48dd6ea826
commit fdf672092a
2 changed files with 27 additions and 14 deletions

View File

@ -30,7 +30,7 @@ export default class NotificationService {
['webhook', this.webhook], ['webhook', this.webhook],
]); ]);
private timeout = 10000; private timeout = 30000;
private title = ''; private title = '';
private content = ''; private content = '';
private params!: Omit<NotificationInfo, 'type'>; private params!: Omit<NotificationInfo, 'type'>;
@ -182,7 +182,8 @@ export default class NotificationService {
telegramBotUserId, telegramBotUserId,
} = this.params; } = this.params;
const authStr = telegramBotProxyAuth ? `${telegramBotProxyAuth}@` : ''; const authStr = telegramBotProxyAuth ? `${telegramBotProxyAuth}@` : '';
const url = `https://${telegramBotApiHost ? telegramBotApiHost : 'api.telegram.org' const url = `https://${
telegramBotApiHost ? telegramBotApiHost : 'api.telegram.org'
}/bot${telegramBotToken}/sendMessage`; }/bot${telegramBotToken}/sendMessage`;
let agent; let agent;
if (telegramBotProxyHost && telegramBotProxyPort) { if (telegramBotProxyHost && telegramBotProxyPort) {
@ -386,10 +387,18 @@ export default class NotificationService {
} }
private async webhook() { private async webhook() {
const { webhookUrl, webhookBody, webhookHeaders, webhookMethod, webhookContentType } = const {
this.params; webhookUrl,
webhookBody,
webhookHeaders,
webhookMethod,
webhookContentType,
} = this.params;
const { formatBody, formatUrl } = this.formatNotifyContent(webhookUrl, webhookBody); const { formatBody, formatUrl } = this.formatNotifyContent(
webhookUrl,
webhookBody,
);
if (!formatUrl && !formatBody) { if (!formatUrl && !formatBody) {
return false; return false;
} }
@ -402,8 +411,8 @@ export default class NotificationService {
timeout: this.timeout, timeout: this.timeout,
retry: 0, retry: 0,
allowGetBody: true, allowGetBody: true,
...bodyParam ...bodyParam,
} };
const res = await got(formatUrl, options); const res = await got(formatUrl, options);
return String(res.statusCode).startsWith('20'); return String(res.statusCode).startsWith('20');
} }
@ -427,8 +436,12 @@ export default class NotificationService {
} }
return { return {
formatUrl: url.replaceAll('$title', encodeURIComponent(this.title)).replaceAll('$content', encodeURIComponent(this.content)), formatUrl: url
formatBody: body.replaceAll('$title', this.title).replaceAll('$content', this.content), .replaceAll('$title', encodeURIComponent(this.title))
} .replaceAll('$content', encodeURIComponent(this.content)),
formatBody: body
.replaceAll('$title', this.title)
.replaceAll('$content', this.content),
};
} }
} }

View File

@ -89,7 +89,7 @@ export default class SystemService {
let lastLog = ''; let lastLog = '';
try { try {
const result = await got.get(config.lastVersionFile, { const result = await got.get(config.lastVersionFile, {
timeout: 6000, timeout: 30000,
retry: 0, retry: 0,
}); });
const lastVersionFileContent = result.body; const lastVersionFileContent = result.body;