diff --git a/pkg/services/notificationservice/notificationService.go b/pkg/services/notificationservice/notificationService.go index c10b0a2..1d1f11b 100644 --- a/pkg/services/notificationservice/notificationService.go +++ b/pkg/services/notificationservice/notificationService.go @@ -157,8 +157,8 @@ func (s *notificationService) CreateNotification( // OriginClass unset, no rules will be applied to this, so the value is not utilized Timestamp: time.Now().Format(time.RFC3339Nano), Title: fmt.Sprintf("Failed to forward notification %q", notification.Title), - Detail: fmt.Sprintf("Could not evaluate alert rules for notification %q after %d retries. No more retries will be attempted, however you can see the notification in this view. Please check the service logs and contact support if the issue persists.", - notification.Title, maxRetries), + Detail: fmt.Sprintf("Could not evaluate alert rules for notification %q from %s after %d retries. No more retries will be attempted for this notification, however you can see the notification in this view. Please check the service logs and contact support if the issue persists.", + notification.Title, notification.Timestamp, maxRetries), Level: notifications.LevelError, }) if err != nil { // we are out of options here, so just log @@ -252,8 +252,8 @@ func (s *notificationService) scheduleRetry(sendTask SendTask) { // OriginClass unset, no rules will be applied to this, so the value is not utilized Timestamp: time.Now().Format(time.RFC3339Nano), Title: fmt.Sprintf("Failed to forward notification %q", sendTask.Notification.Title), - Detail: fmt.Sprintf("A notification could not be forwarded to channel %s after %d retries. No more retries will be attempted, however you can see the notification in this view. Please check the channel configuration and availability if the issue persists.", - sendTask.Action.Channel.Name, sendTask.attempt), + Detail: fmt.Sprintf("Notification %q from %s could not be forwarded to channel %s after %d retries. No more retries will be attempted for this notification, however you can see the notification in this view. Please check the channel configuration and availability if the issue persists.", + sendTask.Notification.Title, sendTask.Notification.Timestamp, sendTask.Action.Channel.Name, sendTask.attempt), Level: notifications.LevelError, }) if err != nil { // we are out of options here, so just log diff --git a/pkg/services/notificationservice/notificationService_test.go b/pkg/services/notificationservice/notificationService_test.go index f2715f4..046bb07 100644 --- a/pkg/services/notificationservice/notificationService_test.go +++ b/pkg/services/notificationservice/notificationService_test.go @@ -216,9 +216,11 @@ func Test_NotificationService_RetryLogic_MaxRetriesReached(t *testing.T) { expectFailedForwardNotification := func(notificationRepo *mocks.NotificationRepository) { notificationRepo.EXPECT().CreateNotification( mock.Anything, - mock.MatchedBy(func(notification models.Notification) bool { - return notification.Title == "Failed to forward notification \"Test Notification\"" && - notification.Level == notifications.LevelError + mock.MatchedBy(func(failureNotification models.Notification) bool { + return failureNotification.Title == "Failed to forward notification \"Test Notification\"" && + strings.Contains(failureNotification.Detail, notification.Title) && + strings.Contains(failureNotification.Detail, notification.Timestamp) && + failureNotification.Level == notifications.LevelError }), ).Return(models.Notification{}, nil).Once() } @@ -245,6 +247,7 @@ func Test_NotificationService_RetryLogic_MaxRetriesReached(t *testing.T) { actions: []models.Action{{ Channel: models.ChannelReference{ ID: teamsChannel.Id, + Name: teamsChannel.ChannelName, Type: models.ChannelTypeTeams, }}, }, @@ -262,6 +265,7 @@ func Test_NotificationService_RetryLogic_MaxRetriesReached(t *testing.T) { { Channel: models.ChannelReference{ ID: mailchannel.Id, + Name: mailchannel.ChannelName, Type: mailchannel.ChannelType, }, Recipient: "success@example.com", @@ -269,6 +273,7 @@ func Test_NotificationService_RetryLogic_MaxRetriesReached(t *testing.T) { { Channel: models.ChannelReference{ ID: mailchannel.Id, + Name: mailchannel.ChannelName, Type: mailchannel.ChannelType, }, Recipient: "failure@example.com", @@ -276,6 +281,7 @@ func Test_NotificationService_RetryLogic_MaxRetriesReached(t *testing.T) { { Channel: models.ChannelReference{ ID: mailchannel.Id, + Name: mailchannel.ChannelName, Type: mailchannel.ChannelType, }, Recipient: "maxRetries@example.com", @@ -325,6 +331,7 @@ func Test_NotificationService_RetryLogic_MaxRetriesReached(t *testing.T) { actions: []models.Action{{ Channel: models.ChannelReference{ ID: mattermostChannel.Id, + Name: mattermostChannel.ChannelName, Type: models.ChannelTypeMattermost, }, }}, @@ -346,6 +353,7 @@ func Test_NotificationService_RetryLogic_MaxRetriesReached(t *testing.T) { actions: []models.Action{{ Channel: models.ChannelReference{ ID: teamsChannel.Id, + Name: teamsChannel.ChannelName, Type: models.ChannelTypeTeams, }, }},