refactor: simplify email sending logic and remove debug checks
- Removed unused `EnvelopeGenerator.Domain.Entities` import. - Changed `SendFinalEmailWithAttachment` calls to explicitly cast envelope email type to `int`. - Removed `Debug` conditional checks around history creation; history commands are now always sent. - Made `SendFinalEmailWithAttachment` a static method for clarity.
This commit is contained in:
parent
d442ad0ce0
commit
fac5419589
@ -1,6 +1,5 @@
|
|||||||
using EnvelopeGenerator.Application.Histories.Commands;
|
using EnvelopeGenerator.Application.Histories.Commands;
|
||||||
using EnvelopeGenerator.Domain.Constants;
|
using EnvelopeGenerator.Domain.Constants;
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
|
||||||
using MediatR;
|
using MediatR;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
@ -67,7 +66,7 @@ public class SendEmailBehavior : IPipelineBehavior<BurnPdfCommand, byte[]>
|
|||||||
|
|
||||||
private async Task SendFinalEmailToCreatorAsync(BurnPdfCommand request, CancellationToken cancel) //, string pAttachment
|
private async Task SendFinalEmailToCreatorAsync(BurnPdfCommand request, CancellationToken cancel) //, string pAttachment
|
||||||
{
|
{
|
||||||
bool oIncludeAttachment = SendFinalEmailWithAttachment(request.Envelope!.FinalEmailToCreator);
|
bool oIncludeAttachment = SendFinalEmailWithAttachment((int)request.Envelope!.FinalEmailToCreator!);
|
||||||
// string oAttachment = string.Empty;
|
// string oAttachment = string.Empty;
|
||||||
|
|
||||||
_logger.LogDebug("Attachment included: [{oIncludeAttachment}]", oIncludeAttachment);
|
_logger.LogDebug("Attachment included: [{oIncludeAttachment}]", oIncludeAttachment);
|
||||||
@ -76,7 +75,6 @@ public class SendEmailBehavior : IPipelineBehavior<BurnPdfCommand, byte[]>
|
|||||||
// oAttachment = pAttachment;
|
// oAttachment = pAttachment;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!request.Debug)
|
|
||||||
await _sender.Send(new CreateHistoryCommand()
|
await _sender.Send(new CreateHistoryCommand()
|
||||||
{
|
{
|
||||||
EnvelopeId = request.Envelope!.Id,
|
EnvelopeId = request.Envelope!.Id,
|
||||||
@ -87,7 +85,7 @@ public class SendEmailBehavior : IPipelineBehavior<BurnPdfCommand, byte[]>
|
|||||||
|
|
||||||
private async Task SendFinalEmailToReceiversAsync(BurnPdfCommand request, CancellationToken cancel) //, string pAttachment
|
private async Task SendFinalEmailToReceiversAsync(BurnPdfCommand request, CancellationToken cancel) //, string pAttachment
|
||||||
{
|
{
|
||||||
bool oIncludeAttachment = SendFinalEmailWithAttachment(request.Envelope!.FinalEmailToReceivers);
|
bool oIncludeAttachment = SendFinalEmailWithAttachment((int)request.Envelope!.FinalEmailToReceivers!);
|
||||||
// string oAttachment = string.Empty;
|
// string oAttachment = string.Empty;
|
||||||
|
|
||||||
_logger.LogDebug("Attachment included: [{oIncludeAttachment}]", oIncludeAttachment);
|
_logger.LogDebug("Attachment included: [{oIncludeAttachment}]", oIncludeAttachment);
|
||||||
@ -97,7 +95,6 @@ public class SendEmailBehavior : IPipelineBehavior<BurnPdfCommand, byte[]>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO update CreateHistoryCommand to be able to create all records together
|
// TODO update CreateHistoryCommand to be able to create all records together
|
||||||
if (!request.Debug)
|
|
||||||
await Task.WhenAll(request.Envelope!.EnvelopeReceivers!.Select(receiver => _sender.Send(new CreateHistoryCommand()
|
await Task.WhenAll(request.Envelope!.EnvelopeReceivers!.Select(receiver => _sender.Send(new CreateHistoryCommand()
|
||||||
{
|
{
|
||||||
EnvelopeId = request.Envelope!.Id,
|
EnvelopeId = request.Envelope!.Id,
|
||||||
@ -105,4 +102,6 @@ public class SendEmailBehavior : IPipelineBehavior<BurnPdfCommand, byte[]>
|
|||||||
UserReference = receiver.Receiver!.EmailAddress,
|
UserReference = receiver.Receiver!.EmailAddress,
|
||||||
}, cancel)));
|
}, cancel)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool SendFinalEmailWithAttachment(int type) => type == (int)FinalEmailType.YesWithAttachment;
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user