Add dynamic email placeholders for confirm/sign workflows
Refactored CreatePlaceholders to set email template values based on whether the envelope requires "read and confirm" or signature. Renamed method parameter for clarity and updated usages. Added a TODO for future method unification. Improves email content accuracy for different envelope actions.
This commit is contained in:
@@ -12,6 +12,7 @@ using EnvelopeGenerator.Application.Common.Dto.EnvelopeReceiverReadOnly;
|
|||||||
using EnvelopeGenerator.Application.Common.Extensions;
|
using EnvelopeGenerator.Application.Common.Extensions;
|
||||||
using EnvelopeGenerator.Application.Common.Interfaces.Services;
|
using EnvelopeGenerator.Application.Common.Interfaces.Services;
|
||||||
using MediatR;
|
using MediatR;
|
||||||
|
using EnvelopeGenerator.Domain.Interfaces;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application.Services;
|
namespace EnvelopeGenerator.Application.Services;
|
||||||
|
|
||||||
@@ -49,14 +50,33 @@ public class EnvelopeMailService : EmailOutService, IEnvelopeMailService
|
|||||||
_sender = sender;
|
_sender = sender;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<Dictionary<string, string>> CreatePlaceholders(string? accessCode = null, EnvelopeReceiverDto? envelopeReceiverDto = null)
|
private async Task<Dictionary<string, string>> CreatePlaceholders(string? accessCode = null, EnvelopeReceiverDto? er = null)
|
||||||
{
|
{
|
||||||
|
if (er!.Envelope.IsReadAndConfirm())
|
||||||
|
{
|
||||||
|
_placeholders["[SIGNATURE_TYPE]"] = "Lesen und bestätigen";
|
||||||
|
_placeholders["[DOCUMENT_PROCESS]"] = string.Empty;
|
||||||
|
_placeholders["[FINAL_STATUS]"] = "Bestätigung";
|
||||||
|
_placeholders["[FINAL_ACTION]"] = "Empfänger bestätigt";
|
||||||
|
_placeholders["[REJECTED_BY_OTHERS]"] = "anderen Empfänger abgelehnt!";
|
||||||
|
_placeholders["[RECEIVER_ACTION]"] = "bestätigt";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_placeholders["[SIGNATURE_TYPE]"] = "Signieren";
|
||||||
|
_placeholders["[DOCUMENT_PROCESS]"] = " und elektronisch unterschreiben";
|
||||||
|
_placeholders["[FINAL_STATUS]"] = "Signatur";
|
||||||
|
_placeholders["[FINAL_ACTION]"] = "Vertragspartner unterzeichnet";
|
||||||
|
_placeholders["[REJECTED_BY_OTHERS]"] = "anderen Vertragspartner abgelehnt! Ihre notwendige Unterzeichnung wurde verworfen.";
|
||||||
|
_placeholders["[RECEIVER_ACTION]"] = "unterschrieben";
|
||||||
|
}
|
||||||
|
|
||||||
if (accessCode is not null)
|
if (accessCode is not null)
|
||||||
_placeholders["[DOCUMENT_ACCESS_CODE]"] = accessCode;
|
_placeholders["[DOCUMENT_ACCESS_CODE]"] = accessCode;
|
||||||
|
|
||||||
if (envelopeReceiverDto?.Envelope is not null && envelopeReceiverDto.Receiver is not null)
|
if (er?.Envelope is not null && er.Receiver is not null)
|
||||||
{
|
{
|
||||||
var erId = (envelopeReceiverDto.Envelope.Uuid, envelopeReceiverDto.Receiver.Signature).ToEnvelopeKey();
|
var erId = (er.Envelope.Uuid, er.Receiver.Signature).ToEnvelopeKey();
|
||||||
var sigHost = await _configService.ReadDefaultSignatureHost();
|
var sigHost = await _configService.ReadDefaultSignatureHost();
|
||||||
var linkToDoc = $"{sigHost}/EnvelopeKey/{erId}";
|
var linkToDoc = $"{sigHost}/EnvelopeKey/{erId}";
|
||||||
_placeholders["[LINK_TO_DOCUMENT]"] = linkToDoc;
|
_placeholders["[LINK_TO_DOCUMENT]"] = linkToDoc;
|
||||||
@@ -66,6 +86,7 @@ public class EnvelopeMailService : EmailOutService, IEnvelopeMailService
|
|||||||
return _placeholders;
|
return _placeholders;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: merge the two CreatePlaceholders methods by using a common parameter object containing all the required information to create the place holders.
|
||||||
private async Task<Dictionary<string, string>> CreatePlaceholders(EnvelopeReceiverReadOnlyDto? readOnlyDto = null)
|
private async Task<Dictionary<string, string>> CreatePlaceholders(EnvelopeReceiverReadOnlyDto? readOnlyDto = null)
|
||||||
{
|
{
|
||||||
if (readOnlyDto?.Envelope is not null && readOnlyDto.Receiver is not null)
|
if (readOnlyDto?.Envelope is not null && readOnlyDto.Receiver is not null)
|
||||||
@@ -124,7 +145,7 @@ public class EnvelopeMailService : EmailOutService, IEnvelopeMailService
|
|||||||
return acResult.ToFail<int>().Notice(LogLevel.Error, "Therefore, access code cannot be sent");
|
return acResult.ToFail<int>().Notice(LogLevel.Error, "Therefore, access code cannot be sent");
|
||||||
var accessCode = acResult.Data;
|
var accessCode = acResult.Data;
|
||||||
|
|
||||||
var placeholders = await CreatePlaceholders(accessCode: accessCode, envelopeReceiverDto: dto);
|
var placeholders = await CreatePlaceholders(accessCode: accessCode, er: dto);
|
||||||
|
|
||||||
// Add optional place holders.
|
// Add optional place holders.
|
||||||
if (optionalPlaceholders is not null)
|
if (optionalPlaceholders is not null)
|
||||||
|
|||||||
Reference in New Issue
Block a user