fix(telegram): Allow ephemeral webhookPort

This commit is contained in:
Harold Hunt
2026-02-26 08:40:33 -05:00
committed by Ayaan Zaidi
parent 296210636d
commit dbfdf60a42
2 changed files with 18 additions and 3 deletions

View File

@@ -15,7 +15,7 @@ describe("Telegram webhookPort config", () => {
expect(res.ok).toBe(true);
});
it("rejects non-positive webhookPort", () => {
it("accepts webhookPort set to 0 for ephemeral port binding", () => {
const res = validateConfigObject({
channels: {
telegram: {
@@ -25,6 +25,19 @@ describe("Telegram webhookPort config", () => {
},
},
});
expect(res.ok).toBe(true);
});
it("rejects negative webhookPort", () => {
const res = validateConfigObject({
channels: {
telegram: {
webhookUrl: "https://example.com/telegram-webhook",
webhookSecret: "secret",
webhookPort: -1,
},
},
});
expect(res.ok).toBe(false);
if (!res.ok) {
expect(res.issues.some((issue) => issue.path === "channels.telegram.webhookPort")).toBe(true);

View File

@@ -193,9 +193,11 @@ export const TelegramAccountSchemaBase = z
webhookPort: z
.number()
.int()
.positive()
.nonnegative()
.optional()
.describe("Local bind port for the webhook listener. Defaults to 8787."),
.describe(
"Local bind port for the webhook listener. Defaults to 8787; set to 0 to let the OS assign an ephemeral port.",
),
actions: z
.object({
reactions: z.boolean().optional(),