From 95a9e4af5bc5906d15ffe574b495db4cbd2a5c06 Mon Sep 17 00:00:00 2001 From: Mo Tarbin Date: Sat, 30 Nov 2024 15:33:54 -0500 Subject: [PATCH] Skip sending Telegram message if bot is not initialized --- internal/notifier/telegram/telegram.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/notifier/telegram/telegram.go b/internal/notifier/telegram/telegram.go index 3f064b6..35afcdd 100644 --- a/internal/notifier/telegram/telegram.go +++ b/internal/notifier/telegram/telegram.go @@ -51,7 +51,12 @@ func (tn *TelegramNotifier) SendChoreReminder(c context.Context, chore *chModel. } func (tn *TelegramNotifier) SendChoreCompletion(c context.Context, chore *chModel.Chore, user *uModel.User) { + log := logging.FromContext(c) + if tn == nil { + log.Error("Telegram bot is not initialized, Skipping sending message") + return + } var mt *chModel.NotificationMetadata if err := json.Unmarshal([]byte(*chore.NotificationMetadata), &mt); err != nil { log.Error("Error unmarshalling notification metadata", err)