aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2017-10-16 02:11:09 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2017-10-16 02:11:09 -0400
commit4e400466deca4fcaf699197d8e30b427c36ea1fe (patch)
treec0097e0782197bae41d5cee787f47c1c04aa4f82
parent4ef9f68837d0c2d2b371239d8568edb6473c6072 (diff)
fix library notifications being sent to all users
-rw-r--r--Emby.Server.Implementations/Notifications/NotificationManager.cs9
-rw-r--r--Emby.Server.Implementations/Notifications/Notifications.cs30
2 files changed, 23 insertions, 16 deletions
diff --git a/Emby.Server.Implementations/Notifications/NotificationManager.cs b/Emby.Server.Implementations/Notifications/NotificationManager.cs
index f49d5a1d1..5b4c43dd5 100644
--- a/Emby.Server.Implementations/Notifications/NotificationManager.cs
+++ b/Emby.Server.Implementations/Notifications/NotificationManager.cs
@@ -38,6 +38,11 @@ namespace Emby.Server.Implementations.Notifications
public Task SendNotification(NotificationRequest request, CancellationToken cancellationToken)
{
+ return SendNotification(request, null, cancellationToken);
+ }
+
+ public Task SendNotification(NotificationRequest request, BaseItem relatedItem, CancellationToken cancellationToken)
+ {
var notificationType = request.NotificationType;
var options = string.IsNullOrWhiteSpace(notificationType) ?
@@ -45,7 +50,9 @@ namespace Emby.Server.Implementations.Notifications
GetConfiguration().GetOptions(notificationType);
var users = GetUserIds(request, options)
- .Select(i => _userManager.GetUserById(i));
+ .Select(i => _userManager.GetUserById(i))
+ .Where(i => relatedItem == null || relatedItem.IsVisibleStandalone(i))
+ .ToArray();
var title = GetTitle(request, options);
var description = GetDescription(request, options);
diff --git a/Emby.Server.Implementations/Notifications/Notifications.cs b/Emby.Server.Implementations/Notifications/Notifications.cs
index 09c1f07e0..b7e1d6559 100644
--- a/Emby.Server.Implementations/Notifications/Notifications.cs
+++ b/Emby.Server.Implementations/Notifications/Notifications.cs
@@ -97,7 +97,7 @@ namespace Emby.Server.Implementations.Notifications
notification.Variables["UserName"] = e.Argument.Name;
- await SendNotification(notification).ConfigureAwait(false);
+ await SendNotification(notification, null).ConfigureAwait(false);
}
async void _deviceManager_CameraImageUploaded(object sender, GenericEventArgs<CameraImageUploadInfo> e)
@@ -111,7 +111,7 @@ namespace Emby.Server.Implementations.Notifications
notification.Variables["DeviceName"] = e.Argument.Device.Name;
- await SendNotification(notification).ConfigureAwait(false);
+ await SendNotification(notification, null).ConfigureAwait(false);
}
async void _appHost_ApplicationUpdated(object sender, GenericEventArgs<PackageVersionInfo> e)
@@ -127,7 +127,7 @@ namespace Emby.Server.Implementations.Notifications
notification.Variables["Version"] = e.Argument.versionStr;
notification.Variables["ReleaseNotes"] = e.Argument.description;
- await SendNotification(notification).ConfigureAwait(false);
+ await SendNotification(notification, null).ConfigureAwait(false);
}
async void _installationManager_PluginUpdated(object sender, GenericEventArgs<Tuple<IPlugin, PackageVersionInfo>> e)
@@ -146,7 +146,7 @@ namespace Emby.Server.Implementations.Notifications
notification.Variables["Version"] = installationInfo.Version.ToString();
notification.Variables["ReleaseNotes"] = e.Argument.Item2.description;
- await SendNotification(notification).ConfigureAwait(false);
+ await SendNotification(notification, null).ConfigureAwait(false);
}
async void _installationManager_PluginInstalled(object sender, GenericEventArgs<PackageVersionInfo> e)
@@ -164,7 +164,7 @@ namespace Emby.Server.Implementations.Notifications
notification.Variables["Name"] = installationInfo.name;
notification.Variables["Version"] = installationInfo.versionStr;
- await SendNotification(notification).ConfigureAwait(false);
+ await SendNotification(notification, null).ConfigureAwait(false);
}
async void _appHost_HasUpdateAvailableChanged(object sender, EventArgs e)
@@ -183,7 +183,7 @@ namespace Emby.Server.Implementations.Notifications
NotificationType = type
};
- await SendNotification(notification).ConfigureAwait(false);
+ await SendNotification(notification, null).ConfigureAwait(false);
}
async void _appHost_HasPendingRestartChanged(object sender, EventArgs e)
@@ -200,7 +200,7 @@ namespace Emby.Server.Implementations.Notifications
NotificationType = type
};
- await SendNotification(notification).ConfigureAwait(false);
+ await SendNotification(notification, null).ConfigureAwait(false);
}
private NotificationOptions GetOptions()
@@ -285,7 +285,7 @@ namespace Emby.Server.Implementations.Notifications
notification.Variables["AppName"] = e.ClientName;
notification.Variables["DeviceName"] = e.DeviceName;
- await SendNotification(notification).ConfigureAwait(false);
+ await SendNotification(notification, null).ConfigureAwait(false);
}
private string GetPlaybackNotificationType(string mediaType)
@@ -390,7 +390,7 @@ namespace Emby.Server.Implementations.Notifications
notification.Variables["Name"] = GetItemName(item);
- await SendNotification(notification).ConfigureAwait(false);
+ await SendNotification(notification, item).ConfigureAwait(false);
}
}
@@ -457,7 +457,7 @@ namespace Emby.Server.Implementations.Notifications
Description = "Check back here for more notifications."
};
- await SendNotification(notification).ConfigureAwait(false);
+ await SendNotification(notification, null).ConfigureAwait(false);
}
async void _taskManager_TaskCompleted(object sender, TaskCompletionEventArgs e)
@@ -478,7 +478,7 @@ namespace Emby.Server.Implementations.Notifications
notification.Variables["Name"] = result.Name;
notification.Variables["ErrorMessage"] = result.ErrorMessage;
- await SendNotification(notification).ConfigureAwait(false);
+ await SendNotification(notification, null).ConfigureAwait(false);
}
}
@@ -496,7 +496,7 @@ namespace Emby.Server.Implementations.Notifications
notification.Variables["Name"] = plugin.Name;
notification.Variables["Version"] = plugin.Version.ToString();
- await SendNotification(notification).ConfigureAwait(false);
+ await SendNotification(notification, null).ConfigureAwait(false);
}
async void _installationManager_PackageInstallationFailed(object sender, InstallationFailedEventArgs e)
@@ -515,14 +515,14 @@ namespace Emby.Server.Implementations.Notifications
notification.Variables["Name"] = installationInfo.Name;
notification.Variables["Version"] = installationInfo.Version;
- await SendNotification(notification).ConfigureAwait(false);
+ await SendNotification(notification, null).ConfigureAwait(false);
}
- private async Task SendNotification(NotificationRequest notification)
+ private async Task SendNotification(NotificationRequest notification, BaseItem relatedItem)
{
try
{
- await _notificationManager.SendNotification(notification, CancellationToken.None).ConfigureAwait(false);
+ await _notificationManager.SendNotification(notification, relatedItem, CancellationToken.None).ConfigureAwait(false);
}
catch (Exception ex)
{