Merge commit from fork

This commit is contained in:
Armin Ronacher
2026-02-01 10:43:54 +01:00
committed by GitHub
parent c621c80afc
commit ca92597e1f
6 changed files with 108 additions and 6 deletions

View File

@@ -164,6 +164,43 @@ export const TelegramConfigSchema = TelegramAccountSchemaBase.extend({
'channels.telegram.dmPolicy="open" requires channels.telegram.allowFrom to include "*"',
});
validateTelegramCustomCommands(value, ctx);
const baseWebhookUrl = typeof value.webhookUrl === "string" ? value.webhookUrl.trim() : "";
const baseWebhookSecret =
typeof value.webhookSecret === "string" ? value.webhookSecret.trim() : "";
if (baseWebhookUrl && !baseWebhookSecret) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: "channels.telegram.webhookUrl requires channels.telegram.webhookSecret",
path: ["webhookSecret"],
});
}
if (!value.accounts) {
return;
}
for (const [accountId, account] of Object.entries(value.accounts)) {
if (!account) {
continue;
}
if (account.enabled === false) {
continue;
}
const accountWebhookUrl =
typeof account.webhookUrl === "string" ? account.webhookUrl.trim() : "";
if (!accountWebhookUrl) {
continue;
}
const accountSecret =
typeof account.webhookSecret === "string" ? account.webhookSecret.trim() : "";
if (!accountSecret && !baseWebhookSecret) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message:
"channels.telegram.accounts.*.webhookUrl requires channels.telegram.webhookSecret or channels.telegram.accounts.*.webhookSecret",
path: ["accounts", accountId, "webhookSecret"],
});
}
}
});
export const DiscordDmSchema = z