diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-04-25 16:15:50 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-04-25 16:15:50 -0400 |
| commit | 547291f04865f23090986667b5a802cd89ea003d (patch) | |
| tree | ff2e4c105979fea94390af6c3614193a0d2a9dc5 /MediaBrowser.Server.Implementations/EntryPoints/Notifications/RemoteNotifications.cs | |
| parent | eda8159b4408c4b33cbdd56e3e6ed2f82757bb0c (diff) | |
rework notifications infrastructure
Diffstat (limited to 'MediaBrowser.Server.Implementations/EntryPoints/Notifications/RemoteNotifications.cs')
| -rw-r--r-- | MediaBrowser.Server.Implementations/EntryPoints/Notifications/RemoteNotifications.cs | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/MediaBrowser.Server.Implementations/EntryPoints/Notifications/RemoteNotifications.cs b/MediaBrowser.Server.Implementations/EntryPoints/Notifications/RemoteNotifications.cs index 723e4fdd3..d5b7f5b36 100644 --- a/MediaBrowser.Server.Implementations/EntryPoints/Notifications/RemoteNotifications.cs +++ b/MediaBrowser.Server.Implementations/EntryPoints/Notifications/RemoteNotifications.cs @@ -1,7 +1,6 @@ using MediaBrowser.Common.Configuration; using MediaBrowser.Common.IO; using MediaBrowser.Common.Net; -using MediaBrowser.Controller.IO; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Notifications; using MediaBrowser.Controller.Plugins; @@ -26,22 +25,23 @@ namespace MediaBrowser.Server.Implementations.EntryPoints.Notifications private readonly IApplicationPaths _appPaths; private readonly ILogger _logger; private readonly IJsonSerializer _json; - private readonly INotificationsRepository _notificationsRepo; private readonly IUserManager _userManager; private readonly IFileSystem _fileSystem; private readonly TimeSpan _frequency = TimeSpan.FromHours(6); private readonly TimeSpan _maxAge = TimeSpan.FromDays(31); - public RemoteNotifications(IApplicationPaths appPaths, ILogger logger, IHttpClient httpClient, IJsonSerializer json, INotificationsRepository notificationsRepo, IUserManager userManager, IFileSystem fileSystem) + private readonly INotificationManager _notificationManager; + + public RemoteNotifications(IApplicationPaths appPaths, ILogger logger, IHttpClient httpClient, IJsonSerializer json, IUserManager userManager, IFileSystem fileSystem, INotificationManager notificationManager) { _appPaths = appPaths; _logger = logger; _httpClient = httpClient; _json = json; - _notificationsRepo = notificationsRepo; _userManager = userManager; _fileSystem = fileSystem; + _notificationManager = notificationManager; } /// <summary> @@ -107,21 +107,19 @@ namespace MediaBrowser.Server.Implementations.EntryPoints.Notifications .Where(i => string.Equals(i.active, "1") && i.date.ToUniversalTime() > lastRunTime && (DateTime.UtcNow - i.date.ToUniversalTime()) <= _maxAge) .ToList(); - foreach (var user in _userManager.Users.ToList()) + var userIds = _userManager.Users.Select(i => i.Id.ToString("N")).ToList(); + + foreach (var notification in notificationList) { - foreach (var notification in notificationList) + await _notificationManager.SendNotification(new NotificationRequest { - await _notificationsRepo.AddNotification(new Notification - { - Category = notification.category, - Date = notification.date, - Name = notification.name, - Description = notification.description, - Url = notification.url, - UserId = user.Id - - }, CancellationToken.None).ConfigureAwait(false); - } + Date = notification.date, + Name = notification.name, + Description = notification.description, + Url = notification.url, + UserIds = userIds + + }, CancellationToken.None).ConfigureAwait(false); } } |
