Skip sending Telegram message if bot is not initialized

This commit is contained in:
Mo Tarbin 2024-11-30 15:33:54 -05:00
parent a8f8550a66
commit 95a9e4af5b

View file

@ -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) { func (tn *TelegramNotifier) SendChoreCompletion(c context.Context, chore *chModel.Chore, user *uModel.User) {
log := logging.FromContext(c) log := logging.FromContext(c)
if tn == nil {
log.Error("Telegram bot is not initialized, Skipping sending message")
return
}
var mt *chModel.NotificationMetadata var mt *chModel.NotificationMetadata
if err := json.Unmarshal([]byte(*chore.NotificationMetadata), &mt); err != nil { if err := json.Unmarshal([]byte(*chore.NotificationMetadata), &mt); err != nil {
log.Error("Error unmarshalling notification metadata", err) log.Error("Error unmarshalling notification metadata", err)