diff --git a/Emby.Server.Implementations/EntryPoints/ServerEventNotifier.cs b/Emby.Server.Implementations/EntryPoints/ServerEventNotifier.cs
index 1ec1f08683..0e50866851 100644
--- a/Emby.Server.Implementations/EntryPoints/ServerEventNotifier.cs
+++ b/Emby.Server.Implementations/EntryPoints/ServerEventNotifier.cs
@@ -1,16 +1,11 @@
using System;
-using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
-using Jellyfin.Data.Entities;
-using Jellyfin.Data.Events;
using MediaBrowser.Common.Plugins;
using MediaBrowser.Common.Updates;
using MediaBrowser.Controller;
-using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Plugins;
using MediaBrowser.Controller.Session;
-using MediaBrowser.Model.Tasks;
using MediaBrowser.Model.Updates;
namespace Emby.Server.Implementations.EntryPoints
@@ -20,11 +15,6 @@ namespace Emby.Server.Implementations.EntryPoints
///
public class ServerEventNotifier : IServerEntryPoint
{
- ///
- /// The user manager.
- ///
- private readonly IUserManager _userManager;
-
///
/// The installation manager.
///
@@ -46,18 +36,15 @@ namespace Emby.Server.Implementations.EntryPoints
/// Initializes a new instance of the class.
///
/// The application host.
- /// The user manager.
/// The installation manager.
/// The task manager.
/// The session manager.
public ServerEventNotifier(
IServerApplicationHost appHost,
- IUserManager userManager,
IInstallationManager installationManager,
ITaskManager taskManager,
ISessionManager sessionManager)
{
- _userManager = userManager;
_installationManager = installationManager;
_appHost = appHost;
_taskManager = taskManager;
@@ -67,8 +54,6 @@ namespace Emby.Server.Implementations.EntryPoints
///
public Task RunAsync()
{
- _userManager.OnUserUpdated += OnUserUpdated;
-
_appHost.HasPendingRestartChanged += OnHasPendingRestartChanged;
_installationManager.PluginUninstalled += OnPluginUninstalled;
@@ -127,18 +112,6 @@ namespace Emby.Server.Implementations.EntryPoints
await _sessionManager.SendRestartRequiredNotification(CancellationToken.None).ConfigureAwait(false);
}
- ///
- /// Users the manager_ user updated.
- ///
- /// The sender.
- /// The e.
- private async void OnUserUpdated(object sender, GenericEventArgs e)
- {
- var dto = _userManager.GetUserDto(e.Argument);
-
- await SendMessageToUserSession(e.Argument, "UserUpdated", dto).ConfigureAwait(false);
- }
-
private async Task SendMessageToAdminSessions(string name, T data)
{
try
@@ -150,21 +123,6 @@ namespace Emby.Server.Implementations.EntryPoints
}
}
- private async Task SendMessageToUserSession(User user, string name, T data)
- {
- try
- {
- await _sessionManager.SendMessageToUserSessions(
- new List { user.Id },
- name,
- data,
- CancellationToken.None).ConfigureAwait(false);
- }
- catch (Exception)
- {
- }
- }
-
///
public void Dispose()
{
@@ -180,8 +138,6 @@ namespace Emby.Server.Implementations.EntryPoints
{
if (dispose)
{
- _userManager.OnUserUpdated -= OnUserUpdated;
-
_installationManager.PluginUninstalled -= OnPluginUninstalled;
_installationManager.PackageInstalling -= OnPackageInstalling;
_installationManager.PackageInstallationCancelled -= OnPackageInstallationCancelled;
diff --git a/Jellyfin.Data/Events/Users/UserUpdatedEventArgs.cs b/Jellyfin.Data/Events/Users/UserUpdatedEventArgs.cs
new file mode 100644
index 0000000000..2b4e49cdf6
--- /dev/null
+++ b/Jellyfin.Data/Events/Users/UserUpdatedEventArgs.cs
@@ -0,0 +1,18 @@
+using Jellyfin.Data.Entities;
+
+namespace Jellyfin.Data.Events.Users
+{
+ ///
+ /// An event that occurs when a user is updated.
+ ///
+ public class UserUpdatedEventArgs : GenericEventArgs
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The user.
+ public UserUpdatedEventArgs(User arg) : base(arg)
+ {
+ }
+ }
+}
diff --git a/Jellyfin.Server.Implementations/Events/Consumers/TaskCompletedLogger.cs b/Jellyfin.Server.Implementations/Events/Consumers/System/TaskCompletedLogger.cs
similarity index 98%
rename from Jellyfin.Server.Implementations/Events/Consumers/TaskCompletedLogger.cs
rename to Jellyfin.Server.Implementations/Events/Consumers/System/TaskCompletedLogger.cs
index 7f737ee7e6..05201a3469 100644
--- a/Jellyfin.Server.Implementations/Events/Consumers/TaskCompletedLogger.cs
+++ b/Jellyfin.Server.Implementations/Events/Consumers/System/TaskCompletedLogger.cs
@@ -11,7 +11,7 @@ using MediaBrowser.Model.Notifications;
using MediaBrowser.Model.Tasks;
using Microsoft.Extensions.Logging;
-namespace Jellyfin.Server.Implementations.Events.Consumers
+namespace Jellyfin.Server.Implementations.Events.Consumers.System
{
///
/// Creates an activity log entry whenever a task is completed.
diff --git a/Jellyfin.Server.Implementations/Events/Consumers/Users/UserUpdatedNotifier.cs b/Jellyfin.Server.Implementations/Events/Consumers/Users/UserUpdatedNotifier.cs
new file mode 100644
index 0000000000..6081dd044f
--- /dev/null
+++ b/Jellyfin.Server.Implementations/Events/Consumers/Users/UserUpdatedNotifier.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+using Jellyfin.Data.Events.Users;
+using MediaBrowser.Controller.Events;
+using MediaBrowser.Controller.Library;
+using MediaBrowser.Controller.Session;
+
+namespace Jellyfin.Server.Implementations.Events.Consumers.Users
+{
+ ///
+ /// Notifies a user when their account has been updated.
+ ///
+ public class UserUpdatedNotifier : IEventConsumer
+ {
+ private readonly IUserManager _userManager;
+ private readonly ISessionManager _sessionManager;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The user manager.
+ /// The session manager.
+ public UserUpdatedNotifier(IUserManager userManager, ISessionManager sessionManager)
+ {
+ _userManager = userManager;
+ _sessionManager = sessionManager;
+ }
+
+ ///
+ public async Task OnEvent(UserUpdatedEventArgs e)
+ {
+ await _sessionManager.SendMessageToUserSessions(
+ new List { e.Argument.Id },
+ "UserUpdated",
+ _userManager.GetUserDto(e.Argument),
+ CancellationToken.None).ConfigureAwait(false);
+ }
+ }
+}
diff --git a/Jellyfin.Server.Implementations/Events/EventingServiceCollectionExtensions.cs b/Jellyfin.Server.Implementations/Events/EventingServiceCollectionExtensions.cs
index 1a43697b8a..84181f4fee 100644
--- a/Jellyfin.Server.Implementations/Events/EventingServiceCollectionExtensions.cs
+++ b/Jellyfin.Server.Implementations/Events/EventingServiceCollectionExtensions.cs
@@ -1,9 +1,9 @@
using Jellyfin.Data.Events;
using Jellyfin.Data.Events.Users;
-using Jellyfin.Server.Implementations.Events.Consumers;
using Jellyfin.Server.Implementations.Events.Consumers.Library;
using Jellyfin.Server.Implementations.Events.Consumers.Security;
using Jellyfin.Server.Implementations.Events.Consumers.Session;
+using Jellyfin.Server.Implementations.Events.Consumers.System;
using Jellyfin.Server.Implementations.Events.Consumers.Updates;
using Jellyfin.Server.Implementations.Events.Consumers.Users;
using MediaBrowser.Common.Updates;
@@ -47,6 +47,8 @@ namespace Jellyfin.Server.Implementations.Events
collection.AddScoped, UserCreatedLogger>();
collection.AddScoped, UserDeletedLogger>();
+ collection.AddScoped, UserDeletedNotifier>();
+ collection.AddScoped, UserUpdatedNotifier>();
collection.AddScoped, UserLockedOutLogger>();
collection.AddScoped, UserPasswordChangedLogger>();