From 147e5520a39bc03b7c0522c1dae7990138939f14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yusuf=20=C4=B0pek?= Date: Sun, 1 Mar 2026 17:28:25 +0300 Subject: [PATCH] feat(notifications): update Telegram bot support and update settings management --- .env.example | 4 + .../settings/settings-page-client.tsx | 90 ++++++++++-------- app/api/settings/notifications/route.ts | 26 +++-- lib/notifications.ts | 5 +- prisma/schema.prisma | 3 +- public/logo.png | Bin 0 -> 86403 bytes 6 files changed, 74 insertions(+), 54 deletions(-) create mode 100644 public/logo.png diff --git a/.env.example b/.env.example index 8d5f47e..c899c45 100644 --- a/.env.example +++ b/.env.example @@ -44,6 +44,10 @@ R2_BUCKET_NAME="openframe" # EMAIL & NOTIFICATIONS # ============================================================================ +# Telegram bot token from @BotFather — shared across all users +# Users only need to provide their own Chat ID in Settings +TELEGRAM_BOT_TOKEN="your-telegram-bot-token" + SMTP_HOST="smtp.gmail.com" SMTP_PORT="587" SMTP_USER="your-email@gmail.com" diff --git a/app/(dashboard)/settings/settings-page-client.tsx b/app/(dashboard)/settings/settings-page-client.tsx index cabfbad..6c64c76 100644 --- a/app/(dashboard)/settings/settings-page-client.tsx +++ b/app/(dashboard)/settings/settings-page-client.tsx @@ -21,7 +21,6 @@ import { import { cn } from '@/lib/utils'; interface NotificationSettings { - telegramBotToken: string | null; telegramChatId: string | null; telegramEnabled: boolean; emailEnabled: boolean; @@ -80,7 +79,6 @@ function ToggleButton({ export default function SettingsPage() { const [settings, setSettings] = useState({ - telegramBotToken: null, telegramChatId: null, telegramEnabled: false, emailEnabled: false, @@ -96,8 +94,7 @@ export default function SettingsPage() { const [testing, setTesting] = useState(null); const [message, setMessage] = useState<{ type: 'success' | 'error'; text: string } | null>(null); - // Form state for Telegram fields (separate from saved settings for editing) - const [telegramToken, setTelegramToken] = useState(''); + // Form state for Telegram chat ID (separate from saved settings for editing) const [telegramChatId, setTelegramChatId] = useState(''); useEffect(() => { @@ -107,7 +104,6 @@ export default function SettingsPage() { if (res.ok) { const data = await res.json(); setSettings(data.data); - setTelegramToken(data.data.telegramBotToken || ''); setTelegramChatId(data.data.telegramChatId || ''); } } catch { @@ -132,7 +128,6 @@ export default function SettingsPage() { headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ ...settings, - telegramBotToken: telegramToken || null, telegramChatId: telegramChatId || null, }), }); @@ -150,7 +145,7 @@ export default function SettingsPage() { } finally { setSaving(false); } - }, [settings, telegramToken, telegramChatId, showMessage]); + }, [settings, telegramChatId, showMessage]); const handleTest = useCallback( async (channel: 'telegram' | 'email') => { @@ -161,7 +156,6 @@ export default function SettingsPage() { headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ channel, - telegramBotToken: telegramToken, telegramChatId, }), }); @@ -177,7 +171,7 @@ export default function SettingsPage() { setTesting(null); } }, - [telegramToken, telegramChatId, showMessage] + [telegramChatId, showMessage] ); if (loading) { @@ -309,49 +303,65 @@ export default function SettingsPage() { - Get instant notifications via a Telegram bot + Get instant notifications via Telegram -
-
- - setTelegramToken(e.target.value)} - className="mt-1 font-mono text-sm" - /> -
-
- - setTelegramChatId(e.target.value)} - className="mt-1 font-mono text-sm" - /> -
+
+

Setup instructions

+
    +
  1. + Message{' '} + + @UserInfeBot + + {' '}on Telegram and send /start to get your Chat ID +
  2. +
  3. + Start{' '} + + @openframe_bot + + {' '}and send /start so it can message you +
  4. +
  5. Paste your Chat ID below and enable notifications
  6. +
-
- - setSettings((s) => ({ ...s, telegramEnabled: !s.telegramEnabled })) - } - label="Enable Telegram notifications" +
+ + setTelegramChatId(e.target.value)} + className="mt-1 font-mono text-sm" />
+ + setSettings((s) => ({ ...s, telegramEnabled: !s.telegramEnabled })) + } + label="Enable Telegram notifications" + /> +