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().
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
using EnvelopeGenerator.Application.Common.Extensions;
|
||||
using EnvelopeGenerator.Domain.Constants;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Common.Interfaces.Services.Notification;
|
||||
|
||||
/// <summary>
|
||||
/// Payload for <see cref="EmailTemplateType.DocumentShared"/> template.
|
||||
/// </summary>
|
||||
public record DocumentSharedNotification : EnvelopeNotificationBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Replaces <c>[DOCUMENT_TITLE]</c> in mail subject/body.
|
||||
/// </summary>
|
||||
public required string DocumentTitle { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Replaces <c>[NAME_RECEIVER]</c> in mail body.
|
||||
/// </summary>
|
||||
public required string NameReceiver { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Base host used to build document link placeholders.
|
||||
/// </summary>
|
||||
public required Uri Origin { private get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Read-only share identifier used to build link placeholders.
|
||||
/// </summary>
|
||||
public required long ReadOnlyId { private get; init; }
|
||||
|
||||
private Uri EnvelopeUrl => new(Origin, $"EnvelopeKey/{ReadOnlyId.ToEnvelopeKey()}");
|
||||
|
||||
/// <summary>
|
||||
/// Replaces <c>[LINK_TO_DOCUMENT]</c> in mail body.
|
||||
/// </summary>
|
||||
public string LinkToDocument => EnvelopeUrl.AbsoluteUri;
|
||||
|
||||
/// <summary>
|
||||
/// Replaces <c>[LINK_TO_DOCUMENT_TEXT]</c> in mail body.
|
||||
/// </summary>
|
||||
public string LinkToDocumentText
|
||||
{
|
||||
get
|
||||
{
|
||||
var urlText = EnvelopeUrl.ToString();
|
||||
return $"{urlText[..Math.Min(urlText.Length, 40)]}..";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Replaces <c>[NAME_PORTAL]</c> in mail body.
|
||||
/// </summary>
|
||||
public string NamePortal { get; init; } = "signFLOW Portal";
|
||||
|
||||
/// <inheritdoc />
|
||||
public override EmailTemplateType GetTemplateType() => EmailTemplateType.DocumentShared;
|
||||
}
|
||||
Reference in New Issue
Block a user