Allow disabling notifications per user and disabling specific notifications per user (#1991)

* Allow disabling notifications per user and disabling specific notifications per use

closes #1974

* Add disable notifs for all users

* fix term generator for notifications

* sow checkboxes instead of multiselect when js is enabled

* remove js dependency

* fix notif conditions
This commit is contained in:
Andrew Camilleri
2020-10-20 13:09:09 +02:00
committed by GitHub
parent 933e0c30bf
commit 4d0b402e8b
20 changed files with 315 additions and 64 deletions

View File

@@ -21,7 +21,6 @@ namespace BTCPayServer.Services.Notifications
private readonly IMemoryCache _memoryCache;
private readonly EventAggregator _eventAggregator;
private readonly Dictionary<string, INotificationHandler> _handlersByNotificationType;
private readonly Dictionary<Type, INotificationHandler> _handlersByBlobType;
public NotificationManager(ApplicationDbContextFactory factory, UserManager<ApplicationUser> userManager,
IMemoryCache memoryCache, IEnumerable<INotificationHandler> handlers, EventAggregator eventAggregator)
@@ -31,7 +30,6 @@ namespace BTCPayServer.Services.Notifications
_memoryCache = memoryCache;
_eventAggregator = eventAggregator;
_handlersByNotificationType = handlers.ToDictionary(h => h.NotificationType);
_handlersByBlobType = handlers.ToDictionary(h => h.NotificationBlobType);
}
private const int _cacheExpiryMs = 5000;
@@ -118,12 +116,5 @@ namespace BTCPayServer.Services.Notifications
return h;
throw new InvalidOperationException($"No INotificationHandler found for {notificationId}");
}
public INotificationHandler GetHandler(Type blobType)
{
if (_handlersByBlobType.TryGetValue(blobType, out var h))
return h;
throw new InvalidOperationException($"No INotificationHandler found for {blobType.Name}");
}
}
}