feat: add support for sending notifications to Telegram group topics (#401)
This commit is contained in:
parent
eaaaa55c90
commit
d449547336
4 changed files with 21 additions and 1 deletions
|
|
@ -86,6 +86,7 @@ const defaultValuesForType = {
|
|||
type: "telegram" as const,
|
||||
botToken: "",
|
||||
chatId: "",
|
||||
threadId: "",
|
||||
},
|
||||
generic: {
|
||||
type: "generic" as const,
|
||||
|
|
|
|||
|
|
@ -39,6 +39,20 @@ export const TelegramForm = ({ form }: Props) => {
|
|||
</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>
|
||||
)}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ export const telegramNotificationConfigSchema = type({
|
|||
type: "'telegram'",
|
||||
botToken: "string",
|
||||
chatId: "string",
|
||||
threadId: "string?",
|
||||
});
|
||||
|
||||
export const genericNotificationConfigSchema = type({
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
import type { NotificationConfig } from "~/schemas/notifications";
|
||||
|
||||
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;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue