aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2013-07-06 22:01:14 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2013-07-06 22:01:14 -0400
commite924efaa6f728e090c498ce51cef6fbe3fb6b47d (patch)
treedff607679ba2631d52130dda313a7793e02642fb
parent734f08f56d333bc66f66b2f6ca9a22d6433b1a39 (diff)
Added a welcome notification
-rw-r--r--MediaBrowser.Controller/Library/IUserManager.cs2
-rw-r--r--MediaBrowser.Server.Implementations/EntryPoints/Notifications/Notifier.cs28
-rw-r--r--MediaBrowser.Server.Implementations/Library/UserManager.cs6
3 files changed, 36 insertions, 0 deletions
diff --git a/MediaBrowser.Controller/Library/IUserManager.cs b/MediaBrowser.Controller/Library/IUserManager.cs
index c485f2b1d..0502ec419 100644
--- a/MediaBrowser.Controller/Library/IUserManager.cs
+++ b/MediaBrowser.Controller/Library/IUserManager.cs
@@ -28,6 +28,8 @@ namespace MediaBrowser.Controller.Library
/// </summary>
event EventHandler<GenericEventArgs<User>> UserDeleted;
+ event EventHandler<GenericEventArgs<User>> UserCreated;
+
/// <summary>
/// Gets a User by Id
/// </summary>
diff --git a/MediaBrowser.Server.Implementations/EntryPoints/Notifications/Notifier.cs b/MediaBrowser.Server.Implementations/EntryPoints/Notifications/Notifier.cs
index 65567d3a8..a97711684 100644
--- a/MediaBrowser.Server.Implementations/EntryPoints/Notifications/Notifier.cs
+++ b/MediaBrowser.Server.Implementations/EntryPoints/Notifications/Notifier.cs
@@ -2,6 +2,7 @@
using MediaBrowser.Common.Plugins;
using MediaBrowser.Common.ScheduledTasks;
using MediaBrowser.Common.Updates;
+using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Notifications;
using MediaBrowser.Controller.Plugins;
@@ -42,6 +43,28 @@ namespace MediaBrowser.Server.Implementations.EntryPoints.Notifications
_installationManager.PluginUninstalled += _installationManager_PluginUninstalled;
_taskManager.TaskCompleted += _taskManager_TaskCompleted;
+
+ _userManager.UserCreated += _userManager_UserCreated;
+ }
+
+ async void _userManager_UserCreated(object sender, GenericEventArgs<User> e)
+ {
+ var notification = new Notification
+ {
+ UserId = e.Argument.Id,
+ Category = "UserCreated",
+ Name = "Welcome to Media Browser!",
+ Description = "Check back here for more notifications."
+ };
+
+ try
+ {
+ await _notificationsRepo.AddNotification(notification, CancellationToken.None).ConfigureAwait(false);
+ }
+ catch (Exception ex)
+ {
+ _logger.ErrorException("Error adding notification", ex);
+ }
}
async void _taskManager_TaskCompleted(object sender, GenericEventArgs<TaskResult> e)
@@ -168,6 +191,11 @@ namespace MediaBrowser.Server.Implementations.EntryPoints.Notifications
{
_installationManager.PackageInstallationCompleted -= _installationManager_PackageInstallationCompleted;
_installationManager.PackageInstallationFailed -= _installationManager_PackageInstallationFailed;
+ _installationManager.PluginUninstalled -= _installationManager_PluginUninstalled;
+
+ _taskManager.TaskCompleted -= _taskManager_TaskCompleted;
+
+ _userManager.UserCreated -= _userManager_UserCreated;
}
}
}
diff --git a/MediaBrowser.Server.Implementations/Library/UserManager.cs b/MediaBrowser.Server.Implementations/Library/UserManager.cs
index e6b218c38..8aedca50f 100644
--- a/MediaBrowser.Server.Implementations/Library/UserManager.cs
+++ b/MediaBrowser.Server.Implementations/Library/UserManager.cs
@@ -303,6 +303,8 @@ namespace MediaBrowser.Server.Implementations.Library
OnUserUpdated(user);
}
+ public event EventHandler<GenericEventArgs<User>> UserCreated;
+
/// <summary>
/// Creates the user.
/// </summary>
@@ -330,6 +332,8 @@ namespace MediaBrowser.Server.Implementations.Library
await UserRepository.SaveUser(user, CancellationToken.None).ConfigureAwait(false);
+ EventHelper.QueueEventIfNotNull(UserCreated, this, new GenericEventArgs<User> { Argument = user }, _logger);
+
return user;
}
@@ -439,5 +443,7 @@ namespace MediaBrowser.Server.Implementations.Library
DateModified = DateTime.UtcNow
};
}
+
+
}
}