From 547291f04865f23090986667b5a802cd89ea003d Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 25 Apr 2014 16:15:50 -0400 Subject: rework notifications infrastructure --- .../Notifications/INotificationManager.cs | 49 ++++++++++++++++++++++ .../Notifications/INotificationsRepository.cs | 19 +++------ .../Notifications/NotificationUpdateEventArgs.cs | 4 +- .../Notifications/UserNotification.cs | 21 ++++++++++ 4 files changed, 77 insertions(+), 16 deletions(-) create mode 100644 MediaBrowser.Controller/Notifications/INotificationManager.cs create mode 100644 MediaBrowser.Controller/Notifications/UserNotification.cs (limited to 'MediaBrowser.Controller/Notifications') diff --git a/MediaBrowser.Controller/Notifications/INotificationManager.cs b/MediaBrowser.Controller/Notifications/INotificationManager.cs new file mode 100644 index 0000000000..8ed62f59f7 --- /dev/null +++ b/MediaBrowser.Controller/Notifications/INotificationManager.cs @@ -0,0 +1,49 @@ +using MediaBrowser.Controller.Entities; +using MediaBrowser.Model.Notifications; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace MediaBrowser.Controller.Notifications +{ + public interface INotificationManager + { + /// + /// Sends the notification. + /// + /// The request. + /// The cancellation token. + /// Task. + Task SendNotification(NotificationRequest request, CancellationToken cancellationToken); + + /// + /// Adds the parts. + /// + /// The services. + void AddParts(IEnumerable services); + } + + public interface INotificationService + { + /// + /// Gets the name. + /// + /// The name. + string Name { get; } + + /// + /// Sends the notification. + /// + /// The request. + /// The cancellation token. + /// Task. + Task SendNotification(UserNotification request, CancellationToken cancellationToken); + + /// + /// Determines whether [is enabled for user] [the specified user identifier]. + /// + /// The user. + /// true if [is enabled for user] [the specified user identifier]; otherwise, false. + bool IsEnabledForUser(User user); + } +} diff --git a/MediaBrowser.Controller/Notifications/INotificationsRepository.cs b/MediaBrowser.Controller/Notifications/INotificationsRepository.cs index 7a4b69b528..87b89e79c8 100644 --- a/MediaBrowser.Controller/Notifications/INotificationsRepository.cs +++ b/MediaBrowser.Controller/Notifications/INotificationsRepository.cs @@ -1,8 +1,7 @@ -using System.Threading; -using MediaBrowser.Controller.Persistence; -using MediaBrowser.Model.Notifications; +using MediaBrowser.Model.Notifications; using System; using System.Collections.Generic; +using System.Threading; using System.Threading.Tasks; namespace MediaBrowser.Controller.Notifications @@ -44,7 +43,7 @@ namespace MediaBrowser.Controller.Notifications /// The id. /// The user id. /// Notification. - Notification GetNotification(Guid id, Guid userId); + Notification GetNotification(string id, string userId); /// /// Adds the notification. @@ -54,14 +53,6 @@ namespace MediaBrowser.Controller.Notifications /// Task. Task AddNotification(Notification notification, CancellationToken cancellationToken); - /// - /// Updates the notification. - /// - /// The notification. - /// The cancellation token. - /// Task. - Task UpdateNotification(Notification notification, CancellationToken cancellationToken); - /// /// Marks the read. /// @@ -70,13 +61,13 @@ namespace MediaBrowser.Controller.Notifications /// if set to true [is read]. /// The cancellation token. /// Task. - Task MarkRead(IEnumerable notificationIdList, Guid userId, bool isRead, CancellationToken cancellationToken); + Task MarkRead(IEnumerable notificationIdList, string userId, bool isRead, CancellationToken cancellationToken); /// /// Gets the notifications summary. /// /// The user id. /// NotificationsSummary. - NotificationsSummary GetNotificationsSummary(Guid userId); + NotificationsSummary GetNotificationsSummary(string userId); } } diff --git a/MediaBrowser.Controller/Notifications/NotificationUpdateEventArgs.cs b/MediaBrowser.Controller/Notifications/NotificationUpdateEventArgs.cs index e156ca26a3..d8a6634dfc 100644 --- a/MediaBrowser.Controller/Notifications/NotificationUpdateEventArgs.cs +++ b/MediaBrowser.Controller/Notifications/NotificationUpdateEventArgs.cs @@ -10,8 +10,8 @@ namespace MediaBrowser.Controller.Notifications public class NotificationReadEventArgs : EventArgs { - public Guid[] IdList { get; set; } - public Guid UserId { get; set; } + public string[] IdList { get; set; } + public string UserId { get; set; } public bool IsRead { get; set; } } } diff --git a/MediaBrowser.Controller/Notifications/UserNotification.cs b/MediaBrowser.Controller/Notifications/UserNotification.cs new file mode 100644 index 0000000000..d035a3995c --- /dev/null +++ b/MediaBrowser.Controller/Notifications/UserNotification.cs @@ -0,0 +1,21 @@ +using MediaBrowser.Controller.Entities; +using MediaBrowser.Model.Notifications; +using System; + +namespace MediaBrowser.Controller.Notifications +{ + public class UserNotification + { + public string Name { get; set; } + + public string Description { get; set; } + + public string Url { get; set; } + + public NotificationLevel Level { get; set; } + + public DateTime Date { get; set; } + + public User User { get; set; } + } +} -- cgit v1.2.3