aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Notifications
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.Server.Implementations/Notifications')
-rw-r--r--Emby.Server.Implementations/Notifications/CoreNotificationTypes.cs12
-rw-r--r--Emby.Server.Implementations/Notifications/NotificationManager.cs10
-rw-r--r--Emby.Server.Implementations/Notifications/Notifications.cs30
3 files changed, 29 insertions, 23 deletions
diff --git a/Emby.Server.Implementations/Notifications/CoreNotificationTypes.cs b/Emby.Server.Implementations/Notifications/CoreNotificationTypes.cs
index 849e02d81..b00b5d43b 100644
--- a/Emby.Server.Implementations/Notifications/CoreNotificationTypes.cs
+++ b/Emby.Server.Implementations/Notifications/CoreNotificationTypes.cs
@@ -160,7 +160,7 @@ namespace Emby.Server.Implementations.Notifications
Update(type);
}
- var systemName = _localization.GetLocalizedString("CategorySystem");
+ var systemName = _localization.GetLocalizedString("System");
return knownTypes.OrderByDescending(i => string.Equals(i.Category, systemName, StringComparison.OrdinalIgnoreCase))
.ThenBy(i => i.Category)
@@ -175,23 +175,23 @@ namespace Emby.Server.Implementations.Notifications
if (note.Type.IndexOf("Playback", StringComparison.OrdinalIgnoreCase) != -1)
{
- note.Category = _localization.GetLocalizedString("CategoryUser");
+ note.Category = _localization.GetLocalizedString("User");
}
else if (note.Type.IndexOf("Plugin", StringComparison.OrdinalIgnoreCase) != -1)
{
- note.Category = _localization.GetLocalizedString("CategoryPlugin");
+ note.Category = _localization.GetLocalizedString("Plugin");
}
else if (note.Type.IndexOf("CameraImageUploaded", StringComparison.OrdinalIgnoreCase) != -1)
{
- note.Category = _localization.GetLocalizedString("CategorySync");
+ note.Category = _localization.GetLocalizedString("Sync");
}
else if (note.Type.IndexOf("UserLockedOut", StringComparison.OrdinalIgnoreCase) != -1)
{
- note.Category = _localization.GetLocalizedString("CategoryUser");
+ note.Category = _localization.GetLocalizedString("User");
}
else
{
- note.Category = _localization.GetLocalizedString("CategorySystem");
+ note.Category = _localization.GetLocalizedString("System");
}
}
}
diff --git a/Emby.Server.Implementations/Notifications/NotificationManager.cs b/Emby.Server.Implementations/Notifications/NotificationManager.cs
index f49d5a1d1..e11f2790e 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);
@@ -69,7 +76,6 @@ namespace Emby.Server.Implementations.Notifications
var tasks = users.Select(i => SendNotification(request, service, title, description, i, cancellationToken));
return Task.WhenAll(tasks);
-
}
private IEnumerable<string> GetUserIds(NotificationRequest request, NotificationOption 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)
{