diff --git a/app/client/api-client/types.gen.ts b/app/client/api-client/types.gen.ts index 058f023..7e82ed3 100644 --- a/app/client/api-client/types.gen.ts +++ b/app/client/api-client/types.gen.ts @@ -1965,6 +1965,10 @@ export type GetScheduleNotificationsResponses = { type: 'pushover'; userKey: string; devices?: string; + } | { + botToken: string; + chatId: string; + type: 'telegram'; } | { from: string; password: string; @@ -2007,7 +2011,7 @@ export type GetScheduleNotificationsResponses = { enabled: boolean; id: number; name: string; - type: 'custom' | 'discord' | 'email' | 'gotify' | 'ntfy' | 'pushover' | 'slack'; + type: 'custom' | 'discord' | 'email' | 'gotify' | 'ntfy' | 'pushover' | 'slack' | 'telegram'; updatedAt: number; }; destinationId: number; @@ -2049,6 +2053,10 @@ export type UpdateScheduleNotificationsResponses = { type: 'pushover'; userKey: string; devices?: string; + } | { + botToken: string; + chatId: string; + type: 'telegram'; } | { from: string; password: string; @@ -2091,7 +2099,7 @@ export type UpdateScheduleNotificationsResponses = { enabled: boolean; id: number; name: string; - type: 'custom' | 'discord' | 'email' | 'gotify' | 'ntfy' | 'pushover' | 'slack'; + type: 'custom' | 'discord' | 'email' | 'gotify' | 'ntfy' | 'pushover' | 'slack' | 'telegram'; updatedAt: number; }; destinationId: number; @@ -2122,6 +2130,10 @@ export type ListNotificationDestinationsResponses = { type: 'pushover'; userKey: string; devices?: string; + } | { + botToken: string; + chatId: string; + type: 'telegram'; } | { from: string; password: string; @@ -2164,7 +2176,7 @@ export type ListNotificationDestinationsResponses = { enabled: boolean; id: number; name: string; - type: 'custom' | 'discord' | 'email' | 'gotify' | 'ntfy' | 'pushover' | 'slack'; + type: 'custom' | 'discord' | 'email' | 'gotify' | 'ntfy' | 'pushover' | 'slack' | 'telegram'; updatedAt: number; }>; }; @@ -2179,6 +2191,10 @@ export type CreateNotificationDestinationData = { type: 'pushover'; userKey: string; devices?: string; + } | { + botToken: string; + chatId: string; + type: 'telegram'; } | { from: string; password: string; @@ -2235,6 +2251,10 @@ export type CreateNotificationDestinationResponses = { type: 'pushover'; userKey: string; devices?: string; + } | { + botToken: string; + chatId: string; + type: 'telegram'; } | { from: string; password: string; @@ -2277,7 +2297,7 @@ export type CreateNotificationDestinationResponses = { enabled: boolean; id: number; name: string; - type: 'custom' | 'discord' | 'email' | 'gotify' | 'ntfy' | 'pushover' | 'slack'; + type: 'custom' | 'discord' | 'email' | 'gotify' | 'ntfy' | 'pushover' | 'slack' | 'telegram'; updatedAt: number; }; }; @@ -2338,6 +2358,10 @@ export type GetNotificationDestinationResponses = { type: 'pushover'; userKey: string; devices?: string; + } | { + botToken: string; + chatId: string; + type: 'telegram'; } | { from: string; password: string; @@ -2380,7 +2404,7 @@ export type GetNotificationDestinationResponses = { enabled: boolean; id: number; name: string; - type: 'custom' | 'discord' | 'email' | 'gotify' | 'ntfy' | 'pushover' | 'slack'; + type: 'custom' | 'discord' | 'email' | 'gotify' | 'ntfy' | 'pushover' | 'slack' | 'telegram'; updatedAt: number; }; }; @@ -2395,6 +2419,10 @@ export type UpdateNotificationDestinationData = { type: 'pushover'; userKey: string; devices?: string; + } | { + botToken: string; + chatId: string; + type: 'telegram'; } | { from: string; password: string; @@ -2461,6 +2489,10 @@ export type UpdateNotificationDestinationResponses = { type: 'pushover'; userKey: string; devices?: string; + } | { + botToken: string; + chatId: string; + type: 'telegram'; } | { from: string; password: string; @@ -2503,7 +2535,7 @@ export type UpdateNotificationDestinationResponses = { enabled: boolean; id: number; name: string; - type: 'custom' | 'discord' | 'email' | 'gotify' | 'ntfy' | 'pushover' | 'slack'; + type: 'custom' | 'discord' | 'email' | 'gotify' | 'ntfy' | 'pushover' | 'slack' | 'telegram'; updatedAt: number; }; }; diff --git a/app/client/modules/notifications/components/create-notification-form.tsx b/app/client/modules/notifications/components/create-notification-form.tsx index 977a083..350536d 100644 --- a/app/client/modules/notifications/components/create-notification-form.tsx +++ b/app/client/modules/notifications/components/create-notification-form.tsx @@ -69,6 +69,11 @@ const defaultValuesForType = { apiToken: "", priority: 0 as const, }, + telegram: { + type: "telegram" as const, + botToken: "", + chatId: "", + }, custom: { type: "custom" as const, shoutrrrUrl: "", @@ -145,6 +150,7 @@ export const CreateNotificationForm = ({ onSubmit, mode = "create", initialValue Gotify Ntfy Pushover + Telegram Custom (Shoutrrr URL) @@ -612,6 +618,41 @@ export const CreateNotificationForm = ({ onSubmit, mode = "create", initialValue > )} + {watchedType === "telegram" && ( + <> + ( + + Bot Token + + + + + Telegram bot token. Get this from BotFather when you create your bot. + + + + )} + /> + ( + + Chat ID + + + + Telegram chat ID to send notifications to. + + + )} + /> + > + )} + {watchedType === "custom" && ( )} - + Save Changes diff --git a/app/client/modules/notifications/routes/notifications.tsx b/app/client/modules/notifications/routes/notifications.tsx index 8ebdfc6..4c3d4f9 100644 --- a/app/client/modules/notifications/routes/notifications.tsx +++ b/app/client/modules/notifications/routes/notifications.tsx @@ -102,6 +102,7 @@ export default function Notifications({ loaderData }: Route.ComponentProps) { Gotify Ntfy Pushover + Telegram Custom diff --git a/app/schemas/notifications.ts b/app/schemas/notifications.ts index 33bafcc..28ff545 100644 --- a/app/schemas/notifications.ts +++ b/app/schemas/notifications.ts @@ -7,6 +7,7 @@ export const NOTIFICATION_TYPES = { gotify: "gotify", ntfy: "ntfy", pushover: "pushover", + telegram: "telegram", custom: "custom", } as const; @@ -64,6 +65,12 @@ export const pushoverNotificationConfigSchema = type({ priority: "-1 | 0 | 1", }); +export const telegramNotificationConfigSchema = type({ + type: "'telegram'", + botToken: "string", + chatId: "string", +}); + export const customNotificationConfigSchema = type({ type: "'custom'", shoutrrrUrl: "string", @@ -75,6 +82,7 @@ export const notificationConfigSchema = emailNotificationConfigSchema .or(gotifyNotificationConfigSchema) .or(ntfyNotificationConfigSchema) .or(pushoverNotificationConfigSchema) + .or(telegramNotificationConfigSchema) .or(customNotificationConfigSchema); export type NotificationConfig = typeof notificationConfigSchema.infer; diff --git a/app/server/modules/notifications/builders/index.ts b/app/server/modules/notifications/builders/index.ts index a6e125c..fae5f3b 100644 --- a/app/server/modules/notifications/builders/index.ts +++ b/app/server/modules/notifications/builders/index.ts @@ -5,6 +5,7 @@ import { buildDiscordShoutrrrUrl } from "./discord"; import { buildGotifyShoutrrrUrl } from "./gotify"; import { buildNtfyShoutrrrUrl } from "./ntfy"; import { buildPushoverShoutrrrUrl } from "./pushover"; +import { buildTelegramShoutrrrUrl } from "./telegram"; import { buildCustomShoutrrrUrl } from "./custom"; export function buildShoutrrrUrl(config: NotificationConfig): string { @@ -21,6 +22,8 @@ export function buildShoutrrrUrl(config: NotificationConfig): string { return buildNtfyShoutrrrUrl(config); case "pushover": return buildPushoverShoutrrrUrl(config); + case "telegram": + return buildTelegramShoutrrrUrl(config); case "custom": return buildCustomShoutrrrUrl(config); default: { diff --git a/app/server/modules/notifications/builders/telegram.ts b/app/server/modules/notifications/builders/telegram.ts new file mode 100644 index 0000000..5c9321c --- /dev/null +++ b/app/server/modules/notifications/builders/telegram.ts @@ -0,0 +1,5 @@ +import type { NotificationConfig } from "~/schemas/notifications"; + +export function buildTelegramShoutrrrUrl(config: Extract): string { + return `telegram://${config.botToken}@telegram?channels=${config.chatId}`; +} diff --git a/app/server/modules/notifications/notifications.service.ts b/app/server/modules/notifications/notifications.service.ts index 678dfc0..4099d8b 100644 --- a/app/server/modules/notifications/notifications.service.ts +++ b/app/server/modules/notifications/notifications.service.ts @@ -65,6 +65,11 @@ async function encryptSensitiveFields(config: NotificationConfig): Promise