forked from boos/BoosAPI
fix: improve tester timeouts and telegram proxy config
This commit is contained in:
@@ -198,4 +198,28 @@ describe('notifyService', () => {
|
||||
expect(payload.text || '').toContain('Local Time:');
|
||||
expect(payload.text || '').toContain('UTC Time:');
|
||||
});
|
||||
|
||||
it('uses TELEGRAM_API_BASE_URL when configured', async () => {
|
||||
const { config } = await import('../config.js');
|
||||
(config as any).telegramEnabled = true;
|
||||
(config as any).telegramBotToken = '123456:telegram-token';
|
||||
(config as any).telegramChatId = '-1001234567890';
|
||||
(config as any).telegramApiBaseUrl = 'https://tg-proxy.example.com/custom/';
|
||||
config.smtpEnabled = false;
|
||||
|
||||
fetchMock.mockResolvedValue({
|
||||
ok: true,
|
||||
status: 200,
|
||||
});
|
||||
|
||||
const { sendNotification } = await import('./notifyService.js');
|
||||
await sendNotification('测试通知', 'message', 'warning', { bypassThrottle: true, throwOnFailure: true });
|
||||
|
||||
expect(fetchMock).toHaveBeenCalledWith(
|
||||
'https://tg-proxy.example.com/custom/bot123456:telegram-token/sendMessage',
|
||||
expect.objectContaining({
|
||||
method: 'POST',
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -218,7 +218,8 @@ export async function sendNotification(
|
||||
}
|
||||
|
||||
if (config.telegramEnabled && config.telegramBotToken && config.telegramChatId) {
|
||||
const telegramApiUrl = `https://api.telegram.org/bot${config.telegramBotToken}/sendMessage`;
|
||||
const telegramApiBaseUrl = String(config.telegramApiBaseUrl || 'https://api.telegram.org').replace(/\/+$/, '');
|
||||
const telegramApiUrl = `${telegramApiBaseUrl}/bot${config.telegramBotToken}/sendMessage`;
|
||||
const text = buildTelegramText(title, resolvedMessage, level, timeFootnote);
|
||||
tasks.push({
|
||||
channel: 'telegram',
|
||||
|
||||
Reference in New Issue
Block a user