diff --git a/MediaBrowser.Model/Notifications/Notification.cs b/MediaBrowser.Model/Notifications/Notification.cs index e69875a68a..e5040373b2 100644 --- a/MediaBrowser.Model/Notifications/Notification.cs +++ b/MediaBrowser.Model/Notifications/Notification.cs @@ -1,6 +1,6 @@ -using System; +using MediaBrowser.Model.Configuration; +using System; using System.Collections.Generic; -using MediaBrowser.Model.Configuration; namespace MediaBrowser.Model.Notifications { @@ -50,13 +50,17 @@ namespace MediaBrowser.Model.Notifications public Dictionary Variables { get; set; } public SendToUserType? SendToUserMode { get; set; } - + + public List ExcludeUserIds { get; set; } + public NotificationRequest() { UserIds = new List(); Date = DateTime.UtcNow; Variables = new Dictionary(StringComparer.OrdinalIgnoreCase); + + ExcludeUserIds = new List(); } } diff --git a/MediaBrowser.Server.Implementations/EntryPoints/Notifications/Notifier.cs b/MediaBrowser.Server.Implementations/EntryPoints/Notifications/Notifier.cs index 06dcf92ff8..217b068bf1 100644 --- a/MediaBrowser.Server.Implementations/EntryPoints/Notifications/Notifier.cs +++ b/MediaBrowser.Server.Implementations/EntryPoints/Notifications/Notifier.cs @@ -149,7 +149,9 @@ namespace MediaBrowser.Server.Implementations.EntryPoints.Notifications var notification = new NotificationRequest { - NotificationType = GetPlaybackNotificationType(item.MediaType) + NotificationType = GetPlaybackNotificationType(item.MediaType), + + ExcludeUserIds = e.Users.Select(i => i.Id.ToString("N")).ToList() }; notification.Variables["ItemName"] = item.Name; diff --git a/MediaBrowser.Server.Implementations/Notifications/NotificationManager.cs b/MediaBrowser.Server.Implementations/Notifications/NotificationManager.cs index 300d2c351e..f3183ec0b0 100644 --- a/MediaBrowser.Server.Implementations/Notifications/NotificationManager.cs +++ b/MediaBrowser.Server.Implementations/Notifications/NotificationManager.cs @@ -38,7 +38,9 @@ namespace MediaBrowser.Server.Implementations.Notifications null : _config.Configuration.NotificationOptions.GetOptions(notificationType); - var users = GetUserIds(request, options).Select(i => _userManager.GetUserById(new Guid(i))); + var users = GetUserIds(request, options) + .Except(request.UserIds) + .Select(i => _userManager.GetUserById(new Guid(i))); var title = GetTitle(request, options); @@ -81,20 +83,10 @@ namespace MediaBrowser.Server.Implementations.Notifications } } - if (options != null) + if (options != null && !string.IsNullOrWhiteSpace(request.NotificationType)) { - switch (options.SendToUserMode) - { - case SendToUserType.Admins: - return _userManager.Users.Where(i => i.Configuration.IsAdministrator) - .Select(i => i.Id.ToString("N")); - case SendToUserType.All: - return _userManager.Users.Select(i => i.Id.ToString("N")); - case SendToUserType.Custom: - return options.SendToUsers; - default: - throw new ArgumentException("Unrecognized SendToUserMode: " + options.SendToUserMode); - } + return _userManager.Users.Where(i => _config.Configuration.NotificationOptions.IsEnabledToSendToUser(request.NotificationType, i.Id.ToString("N"), i.Configuration)) + .Select(i => i.Id.ToString("N")); } return new List(); diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index 91329e9b42..be0925a5f2 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common.Internal - 3.0.355 + 3.0.356 MediaBrowser.Common.Internal Luke ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption. Copyright © Media Browser 2013 - + diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index adef971ce0..c2ac5f7cf0 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.355 + 3.0.356 MediaBrowser.Common Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index ad00362a59..d64be0f3c3 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.355 + 3.0.356 Media Browser.Server.Core Media Browser Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Media Browser Server. Copyright © Media Browser 2013 - +