From bd381642dc30f299ea6d33de6bb27e8047e8f868 Mon Sep 17 00:00:00 2001 From: pablomendezroyo <41727368+pablomendezroyo@users.noreply.github.com> Date: Wed, 11 Dec 2024 14:48:44 +0100 Subject: [PATCH] Send test notification to ensure chat id exists (#80) --- internal/adapters/api/api_adapter.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/adapters/api/api_adapter.go b/internal/adapters/api/api_adapter.go index 6c57a72..d62783e 100644 --- a/internal/adapters/api/api_adapter.go +++ b/internal/adapters/api/api_adapter.go @@ -169,6 +169,13 @@ func (h *APIHandler) UpdateTelegramConfig(w http.ResponseWriter, r *http.Request return } + // send test notification to verify the chat id exists + if err := h.NotifierPort.SendNotification("🙋 Test notification"); err != nil { + logger.ErrorWithPrefix("API", "Failed to send test notification: %v", err) + writeErrorResponse(w, "Failed to send test notification", http.StatusInternalServerError) + return + } + if err := h.StoragePort.SaveTelegramConfig(domain.TelegramConfig(req)); err != nil { logger.ErrorWithPrefix("API", "Failed to update Telegram configuration: %v", err) writeErrorResponse(w, "Failed to update Telegram configuration", http.StatusInternalServerError)