From 41fd50dab76e9e5d8ccaf043fc30860f7efda38c Mon Sep 17 00:00:00 2001 From: pablomendezroyo Date: Thu, 12 Dec 2024 09:40:43 +0100 Subject: [PATCH] send test notification in notifier adapter --- internal/adapters/api/api_adapter.go | 7 ------- internal/adapters/notifier/notifier_adapter.go | 7 +++++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/adapters/api/api_adapter.go b/internal/adapters/api/api_adapter.go index db1020d..fee4833 100644 --- a/internal/adapters/api/api_adapter.go +++ b/internal/adapters/api/api_adapter.go @@ -184,13 +184,6 @@ func (h *APIHandler) UpdateTelegramConfig(w http.ResponseWriter, r *http.Request return } - // Send a test notification after the bot has been updated - if err := h.NotifierPort.SendNotification("🔑 Updated telegram configuration successfully"); err != nil { - logger.ErrorWithPrefix("API", "Failed to send test notification: %v", err) - writeErrorResponse(w, "Failed to send test notification", http.StatusInternalServerError) - return - } - w.WriteHeader(http.StatusOK) } diff --git a/internal/adapters/notifier/notifier_adapter.go b/internal/adapters/notifier/notifier_adapter.go index d248350..3a8f309 100644 --- a/internal/adapters/notifier/notifier_adapter.go +++ b/internal/adapters/notifier/notifier_adapter.go @@ -65,7 +65,14 @@ func (tb *TelegramBot) UpdateBotConfig() error { tb.Bot = bot tb.UserID = config.UserID + + // Send a test notification after the bot has been updated + if err := tb.SendNotification("🔑 Updated telegram configuration successfully"); err != nil { + return fmt.Errorf("failed to send test notification: %w", err) + } + logger.InfoWithPrefix(tb.servicePrefix, "Telegram bot configuration updated successfully.") + return nil }