From 726cff89a8d27a757ec10238acba7743af36d8d7 Mon Sep 17 00:00:00 2001 From: acn-sbuad Date: Mon, 4 Dec 2023 11:46:08 +0100 Subject: [PATCH] logic for setting transient error feedback to new status in db #GCPActive --- README.md | 2 +- .../Enums/EmailNotificationResultType.cs | 15 ++++++++++++++- .../Services/EmailNotificationService.cs | 6 ++++++ .../Services/NotificationSummaryService.cs | 4 +++- 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 81f0c0b0..08e0d1f9 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,6 @@ In pgAdmin To run a Kafka broker and Kafdrop (visualization and administration tool) locally you need to have Docker installed on your machine. In a terminal navigate to the root of this repository -and run command `docker-compose -f setup-kafka.yml up -d` +and run command `docker compose -f setup-kafka.yml up -d` Kafdrop will be available on localhost:9000 diff --git a/src/Altinn.Notifications.Core/Enums/EmailNotificationResultType.cs b/src/Altinn.Notifications.Core/Enums/EmailNotificationResultType.cs index 65813841..2867520c 100644 --- a/src/Altinn.Notifications.Core/Enums/EmailNotificationResultType.cs +++ b/src/Altinn.Notifications.Core/Enums/EmailNotificationResultType.cs @@ -38,5 +38,18 @@ public enum EmailNotificationResultType /// /// Invalid format for email address /// - Failed_InvalidEmailFormat + Failed_InvalidEmailFormat, + + /// + /// Recipient supressed by email service + /// + Failed_SupressedRecipient, + + /// + /// Transient error, retry later + /// + /// + /// Should not be used externally or persisted in db. + /// Only used for processing and logic in service layer. + Failed_TransientError } diff --git a/src/Altinn.Notifications.Core/Services/EmailNotificationService.cs b/src/Altinn.Notifications.Core/Services/EmailNotificationService.cs index 61453805..9386824c 100644 --- a/src/Altinn.Notifications.Core/Services/EmailNotificationService.cs +++ b/src/Altinn.Notifications.Core/Services/EmailNotificationService.cs @@ -72,6 +72,12 @@ public async Task SendNotifications() /// public async Task UpdateSendStatus(SendOperationResult sendOperationResult) { + // set to new to allow new iteration of regular proceessing if transient error + if (sendOperationResult.SendResult == EmailNotificationResultType.Failed_TransientError) + { + sendOperationResult.SendResult = EmailNotificationResultType.New; + } + await _repository.UpdateSendStatus(sendOperationResult.NotificationId, (EmailNotificationResultType)sendOperationResult.SendResult!, sendOperationResult.OperationId); } diff --git a/src/Altinn.Notifications.Core/Services/NotificationSummaryService.cs b/src/Altinn.Notifications.Core/Services/NotificationSummaryService.cs index 54a9326a..e618ce0e 100644 --- a/src/Altinn.Notifications.Core/Services/NotificationSummaryService.cs +++ b/src/Altinn.Notifications.Core/Services/NotificationSummaryService.cs @@ -20,7 +20,9 @@ public class NotificationSummaryService : INotificationSummaryService { EmailNotificationResultType.Delivered, "The email was delivered to the recipient. No errors reported, making it likely it was received by the recipient." }, { EmailNotificationResultType.Failed, "The email was not sent due to an unspecified failure." }, { EmailNotificationResultType.Failed_RecipientNotIdentified, "The email was not sent because the recipient's email address was not found." }, - { EmailNotificationResultType.Failed_InvalidEmailFormat, "The email was not sent because the recipient’s email address is in an invalid format." } + { EmailNotificationResultType.Failed_InvalidEmailFormat, "The email was not sent because the recipient’s email address is in an invalid format." }, + { EmailNotificationResultType.Failed_SupressedRecipient, "The email was not sent because the recipient’s email address is suppressed by the third party email service." }, + { EmailNotificationResultType.Failed_TransientError, "The email was not sent due to a transient error. We will retry sending the email." } }; private readonly static List _successResults = new()