Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pkg/services/notificationservice/notificationService.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
14 changes: 11 additions & 3 deletions pkg/services/notificationservice/notificationService_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand All @@ -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,
}},
},
Expand All @@ -262,20 +265,23 @@ func Test_NotificationService_RetryLogic_MaxRetriesReached(t *testing.T) {
{
Channel: models.ChannelReference{
ID: mailchannel.Id,
Name: mailchannel.ChannelName,
Type: mailchannel.ChannelType,
},
Recipient: "success@example.com",
},
{
Channel: models.ChannelReference{
ID: mailchannel.Id,
Name: mailchannel.ChannelName,
Type: mailchannel.ChannelType,
},
Recipient: "failure@example.com",
},
{
Channel: models.ChannelReference{
ID: mailchannel.Id,
Name: mailchannel.ChannelName,
Type: mailchannel.ChannelType,
},
Recipient: "maxRetries@example.com",
Expand Down Expand Up @@ -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,
},
}},
Expand All @@ -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,
},
}},
Expand Down
Loading