aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/Notifications
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2014-07-02 14:34:08 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2014-07-02 14:34:08 -0400
commit59dc591f66c20b6417aa2baa9503a154585386f9 (patch)
tree68ee71de2e4162550bb95f5e661ef413ddf1e046 /MediaBrowser.Server.Implementations/Notifications
parent9bab99d4d8659e69478722d72028e84b64575ab2 (diff)
update to jquery mobile 1.4.3
Diffstat (limited to 'MediaBrowser.Server.Implementations/Notifications')
-rw-r--r--MediaBrowser.Server.Implementations/Notifications/NotificationConfigurationFactory.cs21
-rw-r--r--MediaBrowser.Server.Implementations/Notifications/NotificationManager.cs16
2 files changed, 33 insertions, 4 deletions
diff --git a/MediaBrowser.Server.Implementations/Notifications/NotificationConfigurationFactory.cs b/MediaBrowser.Server.Implementations/Notifications/NotificationConfigurationFactory.cs
new file mode 100644
index 000000000..a336eba0e
--- /dev/null
+++ b/MediaBrowser.Server.Implementations/Notifications/NotificationConfigurationFactory.cs
@@ -0,0 +1,21 @@
+using MediaBrowser.Common.Configuration;
+using MediaBrowser.Model.Notifications;
+using System.Collections.Generic;
+
+namespace MediaBrowser.Server.Implementations.Notifications
+{
+ public class NotificationConfigurationFactory : IConfigurationFactory
+ {
+ public IEnumerable<ConfigurationStore> GetConfigurations()
+ {
+ return new List<ConfigurationStore>
+ {
+ new ConfigurationStore
+ {
+ Key = "notifications",
+ ConfigurationType = typeof (NotificationOptions)
+ }
+ };
+ }
+ }
+}
diff --git a/MediaBrowser.Server.Implementations/Notifications/NotificationManager.cs b/MediaBrowser.Server.Implementations/Notifications/NotificationManager.cs
index 416b29e86..964e2cd24 100644
--- a/MediaBrowser.Server.Implementations/Notifications/NotificationManager.cs
+++ b/MediaBrowser.Server.Implementations/Notifications/NotificationManager.cs
@@ -1,4 +1,5 @@
-using MediaBrowser.Common.Extensions;
+using MediaBrowser.Common.Configuration;
+using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
@@ -30,13 +31,18 @@ namespace MediaBrowser.Server.Implementations.Notifications
_logger = logManager.GetLogger(GetType().Name);
}
+ private NotificationOptions GetConfiguration()
+ {
+ return _config.GetConfiguration<NotificationOptions>("notifications");
+ }
+
public Task SendNotification(NotificationRequest request, CancellationToken cancellationToken)
{
var notificationType = request.NotificationType;
var options = string.IsNullOrWhiteSpace(notificationType) ?
null :
- _config.Configuration.NotificationOptions.GetOptions(notificationType);
+ GetConfiguration().GetOptions(notificationType);
var users = GetUserIds(request, options)
.Except(request.ExcludeUserIds)
@@ -223,7 +229,7 @@ namespace MediaBrowser.Server.Implementations.Notifications
private bool IsEnabled(INotificationService service, string notificationType)
{
return string.IsNullOrEmpty(notificationType) ||
- _config.Configuration.NotificationOptions.IsServiceEnabled(service.Name, notificationType);
+ GetConfiguration().IsServiceEnabled(service.Name, notificationType);
}
public void AddParts(IEnumerable<INotificationService> services, IEnumerable<INotificationTypeFactory> notificationTypeFactories)
@@ -248,9 +254,11 @@ namespace MediaBrowser.Server.Implementations.Notifications
}).SelectMany(i => i).ToList();
+ var config = GetConfiguration();
+
foreach (var i in list)
{
- i.Enabled = _config.Configuration.NotificationOptions.IsEnabled(i.Type);
+ i.Enabled = config.IsEnabled(i.Type);
}
return list;