This commit is contained in:
@@ -200,13 +200,14 @@ namespace AyaNova.Biz
|
||||
|
||||
private static async Task DeliverSMTP(NotifyEvent ne, AyContext ct)
|
||||
{
|
||||
log.LogTrace($"DeliverSMTP deliving notify event: {ne}");
|
||||
log.LogTrace($"DeliverSMTP delivering notify event: {ne}");
|
||||
if (string.IsNullOrWhiteSpace(ne.NotifySubscription.DeliveryAddress))
|
||||
{
|
||||
await NotifyEventProcessor.AddGeneralNotifyEvent(NotifyEventType.DefaultNotification, $"Error: no email address is set in subscription to deliver email notification for this event:{ne}", null, ne.UserId);
|
||||
|
||||
await NotifyEventProcessor.AddGeneralNotifyEvent(NotifyEventType.GeneralNotification, $"Error: no email address is set in subscription to deliver email notification for this event:{ne}", null, ne.UserId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
var transid = _UserTranslationIdCache[ne.NotifySubscription.UserId];
|
||||
var subject = $"AY:{GetTranslatedNotifyEventName(ne.EventType, transid)}:{ne.Name}";
|
||||
|
||||
@@ -216,17 +217,24 @@ namespace AyaNova.Biz
|
||||
var body = "";
|
||||
if (ne.ObjectId != 0)
|
||||
{
|
||||
body = OpenObjectUrlBuilder(ne.AyaType, ne.ObjectId) + "\n";
|
||||
body = OpenObjectUrlBuilder(ne.AyaType, ne.ObjectId, ne.EventType) + "\n";
|
||||
}
|
||||
body += ne.Message;
|
||||
|
||||
await m.SendEmailAsync(ne.NotifySubscription.DeliveryAddress, subject, body, ServerGlobalOpsSettingsCache.Notify);
|
||||
|
||||
if (!ServerGlobalOpsSettingsCache.Notify.SmtpDeliveryActive)
|
||||
{
|
||||
await NotifyEventProcessor.AddGeneralNotifyEvent(NotifyEventType.GeneralNotification, $"Email notifications are set to OFF at server, unable to send email notification for this event:{ne}", null, ne.UserId);
|
||||
log.LogInformation($"** WARNING: SMTP notification is currently set to Active=False; unable to deliver email notification, re-routed to in-app notification instead [UserId={ne.UserId}, Notify subscription={ne.NotifySubscriptionId}]. Change this setting or have users remove email delivery notifications if this is permanent **");
|
||||
}
|
||||
else
|
||||
{
|
||||
await m.SendEmailAsync(ne.NotifySubscription.DeliveryAddress, subject, body, ServerGlobalOpsSettingsCache.Notify);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await NotifyEventProcessor.AddOpsProblemEvent("SMTP Notification failed", ex);
|
||||
await NotifyEventProcessor.AddGeneralNotifyEvent(NotifyEventType.DefaultNotification, $"Error: an error prevented delivering the following notification via email. System operator users have been notified:{ne}", null, ne.UserId);
|
||||
await NotifyEventProcessor.AddGeneralNotifyEvent(NotifyEventType.GeneralNotification, $"Error: an error prevented delivering the following notification via email. System operator users have been notified:{ne}", null, ne.UserId);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -260,7 +268,7 @@ namespace AyaNova.Biz
|
||||
|
||||
//Open object url
|
||||
//### NOTE: If this is required anywhere else, move it to a central BizUtils class in Biz folder callable from here and there
|
||||
private static string OpenObjectUrlBuilder(AyaType otype, long id)
|
||||
private static string OpenObjectUrlBuilder(AyaType otype, long id, NotifyEventType net)
|
||||
{
|
||||
var ServerUrl = ServerGlobalOpsSettingsCache.Notify.AyaNovaServerURL;
|
||||
if (string.IsNullOrWhiteSpace(ServerUrl))
|
||||
@@ -269,6 +277,21 @@ namespace AyaNova.Biz
|
||||
return "OPS ERROR NO SERVER URL CONFIGURED";
|
||||
}
|
||||
ServerUrl = ServerUrl.Trim().TrimEnd('/');
|
||||
|
||||
//Might not have a type or id in which case nothing directly to open
|
||||
if (otype == AyaType.NoType || id == 0)
|
||||
{
|
||||
return ServerUrl;
|
||||
}
|
||||
|
||||
if (NotifyEventType.ObjectDeleted == net)
|
||||
{
|
||||
//goto event log for item
|
||||
// path: "/history/:ayatype/:recordid/:userlog?",
|
||||
return $"{ServerUrl}/history/{(int)otype}/{id}";
|
||||
}
|
||||
|
||||
//default is to open the object in question directly
|
||||
return $"{ServerUrl}/open/{(int)otype}/{id}";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user