From 73da768ed3b661b71cd17bd3b007f675db55b226 Mon Sep 17 00:00:00 2001 From: TekH Date: Thu, 4 Sep 2025 09:28:13 +0200 Subject: [PATCH] update ConfigEmailOut to add notifications --- .../DocSigned/DocSignedNotification.cs | 16 ++++++++- .../Handlers/SendSignedMailHandler.cs | 35 +++++++++++++++++++ .../Notifications/SendMailHandler.cs | 8 ++--- 3 files changed, 54 insertions(+), 5 deletions(-) create mode 100644 EnvelopeGenerator.Application/Notifications/DocSigned/Handlers/SendSignedMailHandler.cs diff --git a/EnvelopeGenerator.Application/Notifications/DocSigned/DocSignedNotification.cs b/EnvelopeGenerator.Application/Notifications/DocSigned/DocSignedNotification.cs index 353bfd75..138eb480 100644 --- a/EnvelopeGenerator.Application/Notifications/DocSigned/DocSignedNotification.cs +++ b/EnvelopeGenerator.Application/Notifications/DocSigned/DocSignedNotification.cs @@ -1,5 +1,7 @@ using EnvelopeGenerator.Application.Dto.EnvelopeReceiver; +using EnvelopeGenerator.Domain.Constants; using MediatR; +using Newtonsoft.Json; using System.Dynamic; namespace EnvelopeGenerator.Application.Notifications.DocSigned; @@ -8,12 +10,24 @@ namespace EnvelopeGenerator.Application.Notifications.DocSigned; /// /// /// -public record DocSignedNotification(EnvelopeReceiverDto Original) : EnvelopeReceiverDto(Original), INotification +public record DocSignedNotification(EnvelopeReceiverDto Original) : EnvelopeReceiverDto(Original), INotification, ISendMailNotification { /// /// /// public required ExpandoObject Annotations { get; init; } + + /// + /// + /// + public EmailTemplateType TemplateType => EmailTemplateType.DocumentSigned; + + /// + /// + /// + public string EmailAddress => Receiver?.EmailAddress + ?? throw new InvalidOperationException($"Receiver is null." + + $"DocSignedNotification:\n{JsonConvert.SerializeObject(this, Format.Json.ForDiagnostics)}"); } /// diff --git a/EnvelopeGenerator.Application/Notifications/DocSigned/Handlers/SendSignedMailHandler.cs b/EnvelopeGenerator.Application/Notifications/DocSigned/Handlers/SendSignedMailHandler.cs new file mode 100644 index 00000000..e3dceddb --- /dev/null +++ b/EnvelopeGenerator.Application/Notifications/DocSigned/Handlers/SendSignedMailHandler.cs @@ -0,0 +1,35 @@ +using DigitalData.Core.Abstraction.Application.Repository; +using DigitalData.EmailProfilerDispatcher.Abstraction.Entities; +using EnvelopeGenerator.Application.Configurations; +using EnvelopeGenerator.Domain.Entities; +using Microsoft.Extensions.Options; + +namespace EnvelopeGenerator.Application.Notifications.DocSigned.Handlers; + +/// +/// +/// +public class SendSignedMailHandler : SendMailHandler +{ + /// + /// + /// + /// + /// + /// + /// + public SendSignedMailHandler(IRepository tempRepo, IRepository emailOutRepo, IOptions mailParamsOptions, IOptions dispatcherParamsOptions) : base(tempRepo, emailOutRepo, mailParamsOptions, dispatcherParamsOptions) + { + } + + /// + /// + /// + /// + /// + /// + protected override void ConfigEmailOut(DocSignedNotification notification, EmailOut emailOut, CancellationToken cancel) + { + emailOut.ReferenceString = notification.EmailAddress; + } +} diff --git a/EnvelopeGenerator.Application/Notifications/SendMailHandler.cs b/EnvelopeGenerator.Application/Notifications/SendMailHandler.cs index 331fcdbd..15cb9eea 100644 --- a/EnvelopeGenerator.Application/Notifications/SendMailHandler.cs +++ b/EnvelopeGenerator.Application/Notifications/SendMailHandler.cs @@ -63,11 +63,11 @@ public abstract class SendMailHandler : INotificationHandler SubjectPlaceHolders { get; } = new(); /// - /// ReferenceString = Envelope.Uuid + /// /// + /// /// - /// - protected abstract void ConfigEmailOut(EmailOut emailOut); + protected abstract void ConfigEmailOut(TNotification notification, EmailOut emailOut); /// /// @@ -116,7 +116,7 @@ public abstract class SendMailHandler : INotificationHandler