Added a welcome notification

pull/702/head
Luke Pulverenti 12 years ago
parent 734f08f56d
commit e924efaa6f

@ -28,6 +28,8 @@ namespace MediaBrowser.Controller.Library
/// </summary> /// </summary>
event EventHandler<GenericEventArgs<User>> UserDeleted; event EventHandler<GenericEventArgs<User>> UserDeleted;
event EventHandler<GenericEventArgs<User>> UserCreated;
/// <summary> /// <summary>
/// Gets a User by Id /// Gets a User by Id
/// </summary> /// </summary>

@ -2,6 +2,7 @@
using MediaBrowser.Common.Plugins; using MediaBrowser.Common.Plugins;
using MediaBrowser.Common.ScheduledTasks; using MediaBrowser.Common.ScheduledTasks;
using MediaBrowser.Common.Updates; using MediaBrowser.Common.Updates;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Notifications; using MediaBrowser.Controller.Notifications;
using MediaBrowser.Controller.Plugins; using MediaBrowser.Controller.Plugins;
@ -42,6 +43,28 @@ namespace MediaBrowser.Server.Implementations.EntryPoints.Notifications
_installationManager.PluginUninstalled += _installationManager_PluginUninstalled; _installationManager.PluginUninstalled += _installationManager_PluginUninstalled;
_taskManager.TaskCompleted += _taskManager_TaskCompleted; _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) async void _taskManager_TaskCompleted(object sender, GenericEventArgs<TaskResult> e)
@ -168,6 +191,11 @@ namespace MediaBrowser.Server.Implementations.EntryPoints.Notifications
{ {
_installationManager.PackageInstallationCompleted -= _installationManager_PackageInstallationCompleted; _installationManager.PackageInstallationCompleted -= _installationManager_PackageInstallationCompleted;
_installationManager.PackageInstallationFailed -= _installationManager_PackageInstallationFailed; _installationManager.PackageInstallationFailed -= _installationManager_PackageInstallationFailed;
_installationManager.PluginUninstalled -= _installationManager_PluginUninstalled;
_taskManager.TaskCompleted -= _taskManager_TaskCompleted;
_userManager.UserCreated -= _userManager_UserCreated;
} }
} }
} }

@ -303,6 +303,8 @@ namespace MediaBrowser.Server.Implementations.Library
OnUserUpdated(user); OnUserUpdated(user);
} }
public event EventHandler<GenericEventArgs<User>> UserCreated;
/// <summary> /// <summary>
/// Creates the user. /// Creates the user.
/// </summary> /// </summary>
@ -330,6 +332,8 @@ namespace MediaBrowser.Server.Implementations.Library
await UserRepository.SaveUser(user, CancellationToken.None).ConfigureAwait(false); await UserRepository.SaveUser(user, CancellationToken.None).ConfigureAwait(false);
EventHelper.QueueEventIfNotNull(UserCreated, this, new GenericEventArgs<User> { Argument = user }, _logger);
return user; return user;
} }
@ -439,5 +443,7 @@ namespace MediaBrowser.Server.Implementations.Library
DateModified = DateTime.UtcNow DateModified = DateTime.UtcNow
}; };
} }
} }
} }

Loading…
Cancel
Save