This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@@ -33,6 +34,10 @@ namespace AyaNova.Biz
|
||||
private static TimeSpan DELETE_AFTER_AGE = new TimeSpan(90, 0, 0, 0);
|
||||
private static TimeSpan RUN_EVERY_INTERVAL = new TimeSpan(0, 2, 0);//no more frequently than once every 2 minutes
|
||||
#endif
|
||||
|
||||
//temporary list to hold translations as required during delivery
|
||||
private static Dictionary<long, List<NameIdItem>> _transCache = new Dictionary<long, List<NameIdItem>>();
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// DoSweep
|
||||
//
|
||||
@@ -150,6 +155,14 @@ namespace AyaNova.Biz
|
||||
|
||||
}
|
||||
|
||||
//cache any translations required for email notification
|
||||
private static async Task CacheNotifyEventTypeTranslations(long translationId){
|
||||
if(_transCache.ContainsKey(translationId)){
|
||||
return;
|
||||
}
|
||||
_transCache.Add(translationId,AyaNova.Api.Controllers.EnumListController.GetEnumList("NotifyEventType",translationId));
|
||||
}
|
||||
|
||||
private static async Task DeliverInApp(NotifyEvent ne, AyContext ct)
|
||||
{
|
||||
log.LogTrace($"DeliverInApp deliving notify event: {ne}");
|
||||
@@ -158,10 +171,23 @@ namespace AyaNova.Biz
|
||||
await ct.SaveChangesAsync();
|
||||
}
|
||||
|
||||
private static async Task DeliverSMTP(NotifyEvent ne, AyContext ct)
|
||||
private static async Task DeliverSMTP(NotifyEvent ne, string toAddress, AyContext ct)
|
||||
{
|
||||
log.LogTrace($"DeliverSMTP deliving notify event: {ne}");
|
||||
|
||||
var subject = $"Notification: {ne.EventType.ToString()}";
|
||||
|
||||
IMailer m = AyaNova.Util.ServiceProviderProvider.Mailer;
|
||||
try
|
||||
{
|
||||
await m.SendEmailAsync(toAddress, subject, "This is a test to confirm notification system is working", ServerGlobalOpsSettingsCache.Notify);
|
||||
return "ok";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ExceptionUtil.ExtractAllExceptionMessages(ex);
|
||||
}
|
||||
|
||||
//todo: //Open question: what to do with failed deliveries?
|
||||
//we dont' want them piling up but we don't want to just dump them do we?
|
||||
//it should be only mail ones that fail, not app ones, there's no way for an app delivery to fail as it's just put in a table
|
||||
|
||||
Reference in New Issue
Block a user