diff --git a/agent/main.go b/agent/main.go index 2c032b6..13f12be 100644 --- a/agent/main.go +++ b/agent/main.go @@ -91,14 +91,17 @@ func SendNotification(providerType NotificationType, config json.RawMessage, tes func sendTelegramNotification(config json.RawMessage, test NotificationTest) error { var cfg struct { - BotToken string `json:"botToken"` - ChatID string `json:"chatID"` + Token string `json:"token"` + ChatID string `json:"chat_id"` } if err := json.Unmarshal(config, &cfg); err != nil { return fmt.Errorf("invalid Telegram config: %w", err) } + fmt.Println("Token:", cfg.Token) + fmt.Println("ChatID:", cfg.ChatID) + log.Printf("Sending Telegram test to chat %s", cfg.ChatID) return nil } @@ -144,7 +147,7 @@ func getPendingTests() ([]NotificationTest, error) { FROM notification_tests t JOIN notification_providers p ON "t"."notificationProviderId" = p.id - WHERE t.success IS NOT TRUE` + WHERE t.sent IS NOT TRUE` rows, err := db.Query(query) if err != nil { diff --git a/components/cards/settings/NotificationSettings.tsx b/components/cards/settings/NotificationSettings.tsx index 07ad330..c68e7e7 100644 --- a/components/cards/settings/NotificationSettings.tsx +++ b/components/cards/settings/NotificationSettings.tsx @@ -17,7 +17,7 @@ export const NotificationSettings = ({ onError, onSuccess }: { onError: (message const testNotificationHandler = async (notificationProviderId: number) => { (document.getElementById('test_notification') as HTMLDialogElement)?.showModal(); const notificationTest = await testNotification(notificationProviderId); - setNotificationTestId(notificationTest.id); + setNotificationTestId(notificationTest); } return ( diff --git a/components/dialogues/TestNotification.tsx b/components/dialogues/TestNotification.tsx index 3612434..7011223 100644 --- a/components/dialogues/TestNotification.tsx +++ b/components/dialogues/TestNotification.tsx @@ -13,9 +13,11 @@ export default function TestNotification({ notificationTestId }: TestNotificatio const checkNotificationTest = async () => { - console.log(notificationTestId); await getNotificationTest(notificationTestId); } + useEffect(() => { + checkNotificationTest(); + }, [notificationTestId]); return (