From b021d82c1294cbf8142f3bb8ed88287f4089c2e9 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Wed, 21 Oct 2020 15:41:57 +0000 Subject: [PATCH] --- server/AyaNova/generator/CoreJobNotify.cs | 34 +++++++++++++++++++++-- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/server/AyaNova/generator/CoreJobNotify.cs b/server/AyaNova/generator/CoreJobNotify.cs index 4878531a..20da7caf 100644 --- a/server/AyaNova/generator/CoreJobNotify.cs +++ b/server/AyaNova/generator/CoreJobNotify.cs @@ -230,10 +230,11 @@ namespace AyaNova.Biz if (ne.AyaType != AyaType.NoType) AyaTypeTranslated = $":{GetTranslatedAyaTypeName(ne.AyaType, transid)}"; - - var subject = $"AY{AyaTypeTranslated}:{GetTranslatedNotifyEventName(ne.EventType, transid)}:{name}"; + //subscription link translation + var SubscriptionTypeName = $":{GetTranslatedAyaTypeName(AyaType.NotifySubscription, transid)}"; + IMailer m = AyaNova.Util.ServiceProviderProvider.Mailer; try { @@ -242,10 +243,19 @@ namespace AyaNova.Biz if (ne.ObjectId != 0 || ne.EventType == NotifyEventType.BackupStatus) { - body = OpenObjectUrlBuilder(ne.AyaType, ne.ObjectId, ne.EventType) + "\n"; + body = OpenObjectUrlBuilder(ne.AyaType, ne.ObjectId, ne.EventType) + "\n"; } body += ne.Message; + //Add link to subscription + //http://localhost:8080/open/51/1 //add subscription link, notifysub is object type 51 + if (!body.EndsWith('\n')) + { + body += "\n"; + } + + body += $"({SubscriptionTypeName}: {OpenSubscriptionUrlBuilder(ne.NotifySubscriptionId)} )\n"; + 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}", "Error", null, ne.UserId); @@ -343,6 +353,24 @@ namespace AyaNova.Biz return $"{ServerUrl}/viewreport?oid={objectId}&rid={reportId}"; } + + + //url to open subscription for editing + private static string OpenSubscriptionUrlBuilder(long id) + { + var ServerUrl = ServerGlobalOpsSettingsCache.Notify.AyaNovaServerURL; + if (string.IsNullOrWhiteSpace(ServerUrl)) + { + NotifyEventProcessor.AddOpsProblemEvent("Notification system: The OPS Notification setting is empty for AyaNova Server URL. This prevents Notification system from linking events to openable objects.").Wait(); + return "OPS ERROR NO SERVER URL CONFIGURED"; + } + ServerUrl = ServerUrl.Trim().TrimEnd('/'); + + //default is to open the object in question directly + return $"{ServerUrl}/open/{(int)AyaType.NotifySubscription}/{id}"; + } + + ///////////////////////////////////////////////////////////////////// }//eoc