Skip to content

Commit

Permalink
send test notification in notifier adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
pablomendezroyo committed Dec 12, 2024
1 parent 405fa56 commit 41fd50d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
7 changes: 0 additions & 7 deletions internal/adapters/api/api_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
7 changes: 7 additions & 0 deletions internal/adapters/notifier/notifier_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 41fd50d

Please sign in to comment.