From deae4d2acc2d99e1a22496db2b44309ce4d32f1c Mon Sep 17 00:00:00 2001 From: TekH Date: Mon, 16 Nov 2026 09:16:27 +0100 Subject: [PATCH] refactor(notification): derive shared-document links from origin and read-only id Update DocumentSharedNotification to mirror DocumentReceivedNotification URL strategy. Replace externally supplied link strings with init-only Origin and ReadOnlyId inputs and compute LINK_TO_DOCUMENT / LINK_TO_DOCUMENT_TEXT internally via ToEnvelopeKey(). --- .../DocumentSharedNotification.cs | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 EnvelopeGenerator.Application/Common/Interfaces/Services/Notification/DocumentSharedNotification.cs diff --git a/EnvelopeGenerator.Application/Common/Interfaces/Services/Notification/DocumentSharedNotification.cs b/EnvelopeGenerator.Application/Common/Interfaces/Services/Notification/DocumentSharedNotification.cs new file mode 100644 index 00000000..7f3161d9 --- /dev/null +++ b/EnvelopeGenerator.Application/Common/Interfaces/Services/Notification/DocumentSharedNotification.cs @@ -0,0 +1,57 @@ +using EnvelopeGenerator.Application.Common.Extensions; +using EnvelopeGenerator.Domain.Constants; + +namespace EnvelopeGenerator.Application.Common.Interfaces.Services.Notification; + +/// +/// Payload for template. +/// +public record DocumentSharedNotification : EnvelopeNotificationBase +{ + /// + /// Replaces [DOCUMENT_TITLE] in mail subject/body. + /// + public required string DocumentTitle { get; init; } + + /// + /// Replaces [NAME_RECEIVER] in mail body. + /// + public required string NameReceiver { get; init; } + + /// + /// Base host used to build document link placeholders. + /// + public required Uri Origin { private get; init; } + + /// + /// Read-only share identifier used to build link placeholders. + /// + public required long ReadOnlyId { private get; init; } + + private Uri EnvelopeUrl => new(Origin, $"EnvelopeKey/{ReadOnlyId.ToEnvelopeKey()}"); + + /// + /// Replaces [LINK_TO_DOCUMENT] in mail body. + /// + public string LinkToDocument => EnvelopeUrl.AbsoluteUri; + + /// + /// Replaces [LINK_TO_DOCUMENT_TEXT] in mail body. + /// + public string LinkToDocumentText + { + get + { + var urlText = EnvelopeUrl.ToString(); + return $"{urlText[..Math.Min(urlText.Length, 40)]}.."; + } + } + + /// + /// Replaces [NAME_PORTAL] in mail body. + /// + public string NamePortal { get; init; } = "signFLOW Portal"; + + /// + public override EmailTemplateType GetTemplateType() => EmailTemplateType.DocumentShared; +}