From 9a27cbab8c025b5c106e2ecb9dd85060cd90cc87 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 27 Apr 2014 13:54:43 -0400 Subject: added send to user mode --- .../Configuration/NotificationOptions.cs | 77 ++++++++++++++++------ 1 file changed, 56 insertions(+), 21 deletions(-) (limited to 'MediaBrowser.Model/Configuration/NotificationOptions.cs') diff --git a/MediaBrowser.Model/Configuration/NotificationOptions.cs b/MediaBrowser.Model/Configuration/NotificationOptions.cs index 4c0c092fe..84352e7fd 100644 --- a/MediaBrowser.Model/Configuration/NotificationOptions.cs +++ b/MediaBrowser.Model/Configuration/NotificationOptions.cs @@ -14,42 +14,50 @@ namespace MediaBrowser.Model.Configuration new NotificationOption { Type = NotificationType.TaskFailed.ToString(), - Enabled = true + Enabled = true, + SendToUserMode = SendToUserType.Admins }, new NotificationOption { Type = NotificationType.ServerRestartRequired.ToString(), - Enabled = true + Enabled = true, + SendToUserMode = SendToUserType.Admins }, new NotificationOption { Type = NotificationType.ApplicationUpdateAvailable.ToString(), - Enabled = true + Enabled = true, + SendToUserMode = SendToUserType.Admins }, new NotificationOption { Type = NotificationType.ApplicationUpdateInstalled.ToString(), - Enabled = true + Enabled = true, + SendToUserMode = SendToUserType.Admins }, new NotificationOption { Type = NotificationType.PluginUpdateInstalled.ToString(), - Enabled = true + Enabled = true, + SendToUserMode = SendToUserType.Admins }, new NotificationOption { Type = NotificationType.PluginUninstalled.ToString(), - Enabled = true + Enabled = true, + SendToUserMode = SendToUserType.Admins }, new NotificationOption { Type = NotificationType.InstallationFailed.ToString(), - Enabled = true + Enabled = true, + SendToUserMode = SendToUserType.Admins }, new NotificationOption { Type = NotificationType.PluginInstalled.ToString(), - Enabled = true + Enabled = true, + SendToUserMode = SendToUserType.Admins } }; } @@ -82,12 +90,26 @@ namespace MediaBrowser.Model.Configuration !opt.DisabledMonitorUsers.Contains(userId, StringComparer.OrdinalIgnoreCase); } - public bool IsEnabledToSendToUser(string type, string userId) + public bool IsEnabledToSendToUser(string type, string userId, UserConfiguration userConfig) { var opt = GetOptions(type); - return opt != null && opt.Enabled && - !opt.DisabledSendToUsers.Contains(userId, StringComparer.OrdinalIgnoreCase); + if (opt != null && opt.Enabled) + { + if (opt.SendToUserMode == SendToUserType.All) + { + return true; + } + + if (opt.SendToUserMode == SendToUserType.Admins && userConfig.IsAdministrator) + { + return true; + } + + return opt.SendToUsers.Contains(userId, StringComparer.OrdinalIgnoreCase); + } + + return false; } } @@ -101,9 +123,9 @@ namespace MediaBrowser.Model.Configuration public string[] DisabledMonitorUsers { get; set; } /// - /// User Ids to not send to (it's opt out) + /// User Ids to send to (if SendToUserMode == Custom) /// - public string[] DisabledSendToUsers { get; set; } + public string[] SendToUsers { get; set; } /// /// Gets or sets a value indicating whether this is enabled. @@ -122,28 +144,41 @@ namespace MediaBrowser.Model.Configuration /// /// The disabled services. public string[] DisabledServices { get; set; } - + + /// + /// Gets or sets the send to user mode. + /// + /// The send to user mode. + public SendToUserType SendToUserMode { get; set; } + public NotificationOption() { DisabledServices = new string[] { }; DisabledMonitorUsers = new string[] { }; - DisabledSendToUsers = new string[] { }; + SendToUsers = new string[] { }; } } public enum NotificationType { - TaskFailed, - InstallationFailed, - NewLibraryContent, - ServerRestartRequired, ApplicationUpdateAvailable, ApplicationUpdateInstalled, + AudioPlayback, + GamePlayback, + InstallationFailed, PluginInstalled, PluginUpdateInstalled, PluginUninstalled, - AudioPlayback, - GamePlayback, + NewLibraryContent, + ServerRestartRequired, + TaskFailed, VideoPlayback } + + public enum SendToUserType + { + All = 0, + Admins = 1, + Custom = 2 + } } -- cgit v1.2.3