case 4310
This commit is contained in:
@@ -243,8 +243,18 @@ namespace AyaNova.Api.Controllers
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
|
||||
if (!ServerGlobalOpsSettingsCache.Notify.SmtpDeliveryActive)
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_MISSING_PROPERTY, null, "Email notifications are set to OFF at server, unable to send 'on request' type SMTP notification"));
|
||||
|
||||
//validate
|
||||
//for now I'm allowing any authenticated user to call this route intentionally as the use case is for our own internal messaging from the Customer form only or for API users who want to send
|
||||
//email when rendering a report (case 4310).
|
||||
|
||||
//validate incoming data
|
||||
if (string.IsNullOrWhiteSpace(notifyDirectSMTP.Subject))
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_MISSING_PROPERTY, "Subject", "Subject field is required"));
|
||||
|
||||
if (string.IsNullOrWhiteSpace(notifyDirectSMTP.TextBody) && string.IsNullOrWhiteSpace(notifyDirectSMTP.HTMLBody))
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_MISSING_PROPERTY, null, "TextBody or HTMLBody field is required"));
|
||||
|
||||
if (string.IsNullOrWhiteSpace(notifyDirectSMTP.ToAddress))
|
||||
{
|
||||
@@ -277,19 +287,7 @@ namespace AyaNova.Api.Controllers
|
||||
IMailer m = AyaNova.Util.ServiceProviderProvider.Mailer;
|
||||
try
|
||||
{
|
||||
if (!ServerGlobalOpsSettingsCache.Notify.SmtpDeliveryActive)
|
||||
{
|
||||
await NotifyEventHelper.AddGeneralNotifyEvent(NotifyEventType.GeneralNotification,
|
||||
$"Email notifications are set to OFF at server, unable to send 'on request' type SMTP notification subject:{notifyDirectSMTP.Subject}",
|
||||
"Error",
|
||||
null,
|
||||
UserId);
|
||||
log.LogInformation($"** WARNING: SMTP notification is currently set to Active=False; unable to send 'on request' type SMTP notification subject:{notifyDirectSMTP.Subject} **");
|
||||
|
||||
}
|
||||
else
|
||||
await m.SendEmailAsync(notifyDirectSMTP.ToAddress, "Test from Notification system", "This is a test to confirm notification system is working", ServerGlobalOpsSettingsCache.Notify);
|
||||
|
||||
await m.SendEmailAsync(notifyDirectSMTP.ToAddress, "Test from Notification system", "This is a test to confirm notification system is working", ServerGlobalOpsSettingsCache.Notify);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user