From c5e4669fdab01f12abd6b220d07acfb347900c8b Mon Sep 17 00:00:00 2001 From: Cubicroot Date: Fri, 11 Jun 2021 10:21:48 +0200 Subject: [PATCH] clean up --- internal/dispatcher/notification.go | 11 ++++++++--- internal/model/notification.go | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/internal/dispatcher/notification.go b/internal/dispatcher/notification.go index 9b974d0..6571d8d 100644 --- a/internal/dispatcher/notification.go +++ b/internal/dispatcher/notification.go @@ -82,10 +82,15 @@ func (d *Dispatcher) DeleteNotification(a *model.Application, n *model.DeleteNot if val, ok := deleteMessage.Content["body"]; ok { body, ok := val.(string) - if ok { - oldBody = body - oldFormattedBody = body + + if !ok { + log.Println("Event does not have a body") + return api.ErrorMessageNotFound } + + oldBody = body + oldFormattedBody = body + } else { log.Println("Message to delete has wrong format") return api.ErrorMessageNotFound diff --git a/internal/model/notification.go b/internal/model/notification.go index 569e8ee..fc46221 100644 --- a/internal/model/notification.go +++ b/internal/model/notification.go @@ -16,7 +16,7 @@ type Notification struct { Date time.Time `json:"date"` } -// DeleteNotification holds information like the message, the reply to message id and the priority of a deletion notification. +// DeleteNotification holds information like the message ID of a deletion notification. type DeleteNotification struct { ID string `json:"id" form:"id"` Date time.Time `json:"date"`