Telegram: improve webhook config guidance and startup fallback

This commit is contained in:
Harold Hunt
2026-02-25 22:06:08 -05:00
committed by Ayaan Zaidi
parent 5416cabdf8
commit 840b768d97
3 changed files with 42 additions and 6 deletions

View File

@@ -207,6 +207,7 @@ describe("startTelegramWebhook", () => {
initSpy.mockClear();
createTelegramBotSpy.mockClear();
webhookCallbackSpy.mockClear();
const runtimeLog = vi.fn();
const abort = new AbortController();
const cfg = { bindings: [] };
const { server } = await startTelegramWebhook({
@@ -216,6 +217,7 @@ describe("startTelegramWebhook", () => {
config: cfg,
port: 0, // random free port
abortSignal: abort.signal,
runtime: { log: runtimeLog, error: vi.fn(), exit: vi.fn() },
});
expect(createTelegramBotSpy).toHaveBeenCalledWith(
expect.objectContaining({
@@ -246,6 +248,13 @@ describe("startTelegramWebhook", () => {
timeoutMilliseconds: 10_000,
},
);
expect(runtimeLog).toHaveBeenCalledWith(
expect.stringContaining("webhook local listener on http://127.0.0.1:"),
);
expect(runtimeLog).toHaveBeenCalledWith(expect.stringContaining("/telegram-webhook"));
expect(runtimeLog).toHaveBeenCalledWith(
expect.stringContaining("webhook advertised to telegram on http://"),
);
abort.abort();
});

View File

@@ -250,7 +250,8 @@ export async function startTelegramWebhook(opts: {
throw err;
}
runtime.log?.(`webhook listening on ${publicUrl}`);
runtime.log?.(`webhook local listener on http://${host}:${port}${path}`);
runtime.log?.(`webhook advertised to telegram on ${publicUrl}`);
let shutDown = false;
const shutdown = () => {