refactor(email): replace Task.WhenAll with foreach in SendEmailBehavior
Changed the SendFinalEmailToReceiversAsync method to use a sequential `foreach` loop instead of `Task.WhenAll` for sending history commands. Added a null check for receiver emails to prevent potential exceptions.
This commit is contained in:
parent
fac5419589
commit
35dd2e8e07
@ -95,12 +95,18 @@ 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
|
||||||
await Task.WhenAll(request.Envelope!.EnvelopeReceivers!.Select(receiver => _sender.Send(new CreateHistoryCommand()
|
foreach (var receiver in request.Envelope.EnvelopeReceivers!)
|
||||||
{
|
{
|
||||||
EnvelopeId = request.Envelope!.Id,
|
if (receiver.Receiver?.EmailAddress != null)
|
||||||
Status = EnvelopeStatus.MessageCompletionSent,
|
{
|
||||||
UserReference = receiver.Receiver!.EmailAddress,
|
await _sender.Send(new CreateHistoryCommand()
|
||||||
}, cancel)));
|
{
|
||||||
|
EnvelopeId = request.Envelope.Id,
|
||||||
|
Status = EnvelopeStatus.MessageCompletionSent,
|
||||||
|
UserReference = receiver.Receiver.EmailAddress,
|
||||||
|
}, cancel);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool SendFinalEmailWithAttachment(int type) => type == (int)FinalEmailType.YesWithAttachment;
|
private static bool SendFinalEmailWithAttachment(int type) => type == (int)FinalEmailType.YesWithAttachment;
|
||||||
|
|||||||
@ -110,6 +110,8 @@ public class BurnPdfCommandHandler : IRequestHandler<BurnPdfCommand, byte[]>
|
|||||||
|
|
||||||
request.Envelope = await envQuery
|
request.Envelope = await envQuery
|
||||||
.Include(env => env.Documents!).ThenInclude(doc => doc.Elements!).ThenInclude(element => element.Annotations)
|
.Include(env => env.Documents!).ThenInclude(doc => doc.Elements!).ThenInclude(element => element.Annotations)
|
||||||
|
.Include(env => env.User)
|
||||||
|
.Include(env => env.EnvelopeReceivers!).ThenInclude(envRcv => envRcv.Receiver)
|
||||||
.FirstOrDefaultAsync(cancel)
|
.FirstOrDefaultAsync(cancel)
|
||||||
?? throw new BadRequestException($"Envelope could not be found. Request details:\n" +
|
?? throw new BadRequestException($"Envelope could not be found. Request details:\n" +
|
||||||
request.ToJson(Format.Json.ForDiagnostics));
|
request.ToJson(Format.Json.ForDiagnostics));
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
"Default": "Information",
|
"Default": "Error",
|
||||||
"Microsoft.Hosting.Lifetime": "Information"
|
"Microsoft.Hosting.Lifetime": "Information"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,8 +1,11 @@
|
|||||||
{
|
{
|
||||||
"FinishEnvelopeJob": {
|
"FinishEnvelopeJob": {
|
||||||
"CronExpression": "* * * * * ?"
|
"CronExpression": "0 0/1 * 1/1 * ? *"
|
||||||
},
|
},
|
||||||
"EnvelopeTaskApiJob": {
|
"EnvelopeTaskApiJob": {
|
||||||
"CronExpression": "* * * * * ?"
|
"CronExpression": "0 0/1 * 1/1 * ? *"
|
||||||
|
}
|
||||||
|
"Expressions": {
|
||||||
|
"PerSec": "* * * * * ?"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user