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().
58 lines
1.7 KiB
C#
58 lines
1.7 KiB
C#
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;
|
|
}
|