From 9c48b230b48f4441b9352b1b31a4d174f3b02db6 Mon Sep 17 00:00:00 2001 From: TekH Date: Thu, 4 Sep 2025 17:01:40 +0200 Subject: [PATCH] convert PlaceHolders-property to CreatePlaceHolders callback-method --- .../DocSigned/Handlers/SendSignedMailHandler.cs | 16 +++++++++++++++- .../Notifications/SendMailHandler.cs | 13 +++++++------ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/EnvelopeGenerator.Application/Notifications/DocSigned/Handlers/SendSignedMailHandler.cs b/EnvelopeGenerator.Application/Notifications/DocSigned/Handlers/SendSignedMailHandler.cs index 8cfcf467..eb06c026 100644 --- a/EnvelopeGenerator.Application/Notifications/DocSigned/Handlers/SendSignedMailHandler.cs +++ b/EnvelopeGenerator.Application/Notifications/DocSigned/Handlers/SendSignedMailHandler.cs @@ -27,12 +27,26 @@ public class SendSignedMailHandler : SendMailHandler /// /// /// - protected override void ConfigEmailOut(DocSignedNotification notification, EmailOut emailOut) + protected override void ConfigureEmailOut(DocSignedNotification notification, EmailOut emailOut) { emailOut.ReferenceString = notification.EmailAddress; emailOut.ReferenceId = notification.ReceiverId; } + /// + /// + /// + /// + /// + protected override Dictionary CreatePlaceHolders(DocSignedNotification notification) + { + var placeHolders = new Dictionary() + { + }; + + return placeHolders; + } + private static string TextToHtml(string input) { if (string.IsNullOrEmpty(input)) return ""; diff --git a/EnvelopeGenerator.Application/Notifications/SendMailHandler.cs b/EnvelopeGenerator.Application/Notifications/SendMailHandler.cs index 0ede6fe0..fe12dc77 100644 --- a/EnvelopeGenerator.Application/Notifications/SendMailHandler.cs +++ b/EnvelopeGenerator.Application/Notifications/SendMailHandler.cs @@ -45,7 +45,7 @@ public abstract class SendMailHandler : INotificationHandler /// /// - protected virtual Dictionary PlaceHolders { get; } = new(); + protected abstract Dictionary CreatePlaceHolders(TNotification notification); /// /// @@ -62,7 +62,7 @@ public abstract class SendMailHandler : INotificationHandler /// /// - protected abstract void ConfigEmailOut(TNotification notification, EmailOut emailOut); + protected abstract void ConfigureEmailOut(TNotification notification, EmailOut emailOut); /// /// @@ -86,17 +86,18 @@ public abstract class SendMailHandler : INotificationHandler /// /// - public async Task Handle(TNotification notification, CancellationToken cancel) + public virtual async Task Handle(TNotification notification, CancellationToken cancel) { + var placeHolders = CreatePlaceHolders(notification); var temp = await TempRepo .ReadOnly() .SingleOrDefaultAsync(x => x.Name == notification.TemplateType.ToString(), cancel) ?? throw new InvalidOperationException($"Receiver information is missing in the notification." + $"{typeof(TNotification)}:\n {JsonConvert.SerializeObject(notification, Format.Json.ForDiagnostics)}"); - temp.Subject = ReplacePlaceHolders(temp.Subject, PlaceHolders, MailParams.Placeholders); + temp.Subject = ReplacePlaceHolders(temp.Subject, placeHolders, MailParams.Placeholders); - temp.Body = ReplacePlaceHolders(temp.Body, PlaceHolders, MailParams.Placeholders); + temp.Body = ReplacePlaceHolders(temp.Body, placeHolders, MailParams.Placeholders); var emailOut = new EmailOut { @@ -111,7 +112,7 @@ public abstract class SendMailHandler : INotificationHandler