From 91707f13a877dd4e8b70d0857f0343215be76758 Mon Sep 17 00:00:00 2001 From: Bond-009 Date: Tue, 4 Feb 2020 12:29:14 +0100 Subject: [PATCH] Add endpoints back --- .../Api/NotificationsService.cs | 105 +++++++++++++++++- jellyfin.ruleset | 2 + 2 files changed, 105 insertions(+), 2 deletions(-) diff --git a/Emby.Notifications/Api/NotificationsService.cs b/Emby.Notifications/Api/NotificationsService.cs index 5591809712..f9e923d10b 100644 --- a/Emby.Notifications/Api/NotificationsService.cs +++ b/Emby.Notifications/Api/NotificationsService.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -17,6 +18,62 @@ using MediaBrowser.Model.Services; namespace Emby.Notifications.Api { + [Route("/Notifications/{UserId}", "GET", Summary = "Gets notifications")] + public class GetNotifications : IReturn + { + [ApiMember(Name = "UserId", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")] + public string UserId { get; set; } + + [ApiMember(Name = "IsRead", Description = "An optional filter by IsRead", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")] + public bool? IsRead { get; set; } + + [ApiMember(Name = "StartIndex", Description = "Optional. The record index to start at. All items with a lower index will be dropped from the results.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")] + public int? StartIndex { get; set; } + + [ApiMember(Name = "Limit", Description = "Optional. The maximum number of records to return", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")] + public int? Limit { get; set; } + } + + public class Notification + { + public string Id { get; set; } + + public string UserId { get; set; } + + public DateTime Date { get; set; } + + public bool IsRead { get; set; } + + public string Name { get; set; } + + public string Description { get; set; } + + public string Url { get; set; } + + public NotificationLevel Level { get; set; } + } + + public class NotificationResult + { + public IReadOnlyList Notifications { get; set; } + + public int TotalRecordCount { get; set; } + } + + public class NotificationsSummary + { + public int UnreadCount { get; set; } + + public NotificationLevel MaxUnreadNotificationLevel { get; set; } + } + + [Route("/Notifications/{UserId}/Summary", "GET", Summary = "Gets a notification summary for a user")] + public class GetNotificationsSummary : IReturn + { + [ApiMember(Name = "UserId", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")] + public string UserId { get; set; } + } + [Route("/Notifications/Types", "GET", Summary = "Gets notification types")] public class GetNotificationTypes : IReturn> { @@ -46,6 +103,26 @@ namespace Emby.Notifications.Api public NotificationLevel Level { get; set; } } + [Route("/Notifications/{UserId}/Read", "POST", Summary = "Marks notifications as read")] + public class MarkRead : IReturnVoid + { + [ApiMember(Name = "UserId", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")] + public string UserId { get; set; } + + [ApiMember(Name = "Ids", Description = "A list of notification ids, comma delimited", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST", AllowMultiple = true)] + public string Ids { get; set; } + } + + [Route("/Notifications/{UserId}/Unread", "POST", Summary = "Marks notifications as unread")] + public class MarkUnread : IReturnVoid + { + [ApiMember(Name = "UserId", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")] + public string UserId { get; set; } + + [ApiMember(Name = "Ids", Description = "A list of notification ids, comma delimited", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST", AllowMultiple = true)] + public string Ids { get; set; } + } + [Authenticated] public class NotificationsService : IService { @@ -58,18 +135,26 @@ namespace Emby.Notifications.Api _userManager = userManager; } + [SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "request")] public object Get(GetNotificationTypes request) { - _ = request; // Silence unused variable warning return _notificationManager.GetNotificationTypes(); } + [SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "request")] public object Get(GetNotificationServices request) { - _ = request; // Silence unused variable warning return _notificationManager.GetNotificationServices().ToList(); } + [SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "request")] + public object Get(GetNotificationsSummary request) + { + return new NotificationsSummary + { + }; + } + public Task Post(AddAdminNotification request) { // This endpoint really just exists as post of a real with sickbeard @@ -85,5 +170,21 @@ namespace Emby.Notifications.Api return _notificationManager.SendNotification(notification, CancellationToken.None); } + + [SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "request")] + public void Post(MarkRead request) + { + } + + [SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "request")] + public void Post(MarkUnread request) + { + } + + [SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "request")] + public object Get(GetNotifications request) + { + return new NotificationResult(); + } } } diff --git a/jellyfin.ruleset b/jellyfin.ruleset index 92b7a03fdd..e4d2831677 100644 --- a/jellyfin.ruleset +++ b/jellyfin.ruleset @@ -5,6 +5,8 @@ + +