feat: add support for sending notifications to Telegram group topics

This commit is contained in:
Didin Sino 2026-01-23 01:05:18 +07:00
parent da37b08fa0
commit 61014eae72
4 changed files with 21 additions and 1 deletions

View file

@ -86,6 +86,7 @@ const defaultValuesForType = {
type: "telegram" as const, type: "telegram" as const,
botToken: "", botToken: "",
chatId: "", chatId: "",
threadId: "",
}, },
generic: { generic: {
type: "generic" as const, type: "generic" as const,

View file

@ -39,6 +39,20 @@ export const TelegramForm = ({ form }: Props) => {
</FormItem> </FormItem>
)} )}
/> />
<FormField
control={form.control}
name="threadId"
render={({ field }) => (
<FormItem>
<FormLabel>Thread ID (Optional)</FormLabel>
<FormControl>
<Input {...field} placeholder="3" />
</FormControl>
<FormDescription>Telegram Group Topic ID to send notifications to.</FormDescription>
<FormMessage />
</FormItem>
)}
/>
</> </>
); );
}; };

View file

@ -71,6 +71,7 @@ export const telegramNotificationConfigSchema = type({
type: "'telegram'", type: "'telegram'",
botToken: "string", botToken: "string",
chatId: "string", chatId: "string",
threadId: "string?",
}); });
export const genericNotificationConfigSchema = type({ export const genericNotificationConfigSchema = type({

View file

@ -1,5 +1,9 @@
import type { NotificationConfig } from "~/schemas/notifications"; import type { NotificationConfig } from "~/schemas/notifications";
export const buildTelegramShoutrrrUrl = (config: Extract<NotificationConfig, { type: "telegram" }>) => { export const buildTelegramShoutrrrUrl = (config: Extract<NotificationConfig, { type: "telegram" }>) => {
return `telegram://${config.botToken}@telegram?channels=${config.chatId}`; let shoutrrrUrl = `telegram://${config.botToken}@telegram?channels=${config.chatId}`;
if (config.threadId) {
shoutrrrUrl += `:${config.threadId}`;
}
return shoutrrrUrl;
}; };