Jelajahi Sumber

Address PR comments, and revert changes that changed the API schema

ZadenRB 5 tahun lalu
induk
melakukan
7c8188194b

+ 10 - 10
Jellyfin.Api/Controllers/NotificationsController.cs

@@ -42,13 +42,13 @@ namespace Jellyfin.Api.Controllers
         /// <param name="limit">An optional limit on the number of notifications returned.</param>
         /// <returns>A read-only list of all of the user's notifications.</returns>
         [HttpGet("{UserID}")]
-        public IReadOnlyList<NotificationDto> GetNotifications(
+        public NotificationResultDto GetNotifications(
             [FromRoute] string userId,
             [FromQuery] bool? isRead,
             [FromQuery] int? startIndex,
             [FromQuery] int? limit)
         {
-            return new List<NotificationDto>();
+            return new NotificationResultDto();
         }
 
         /// <summary>
@@ -92,10 +92,10 @@ namespace Jellyfin.Api.Controllers
         /// <param name="level">The level of the notification.</param>
         [HttpPost("Admin")]
         public void CreateAdminNotification(
-            [FromForm] string name,
-            [FromForm] string description,
-            [FromForm] string? url,
-            [FromForm] NotificationLevel? level)
+            [FromQuery] string name,
+            [FromQuery] string description,
+            [FromQuery] string? url,
+            [FromQuery] NotificationLevel? level)
         {
             var notification = new NotificationRequest
             {
@@ -114,11 +114,11 @@ namespace Jellyfin.Api.Controllers
         /// Endpoint to set notifications as read.
         /// </summary>
         /// <param name="userId">The userID.</param>
-        /// <param name="ids">The IDs of notifications which should be set as read.</param>
+        /// <param name="ids">A comma-separated list of the IDs of notifications which should be set as read.</param>
         [HttpPost("{UserID}/Read")]
         public void SetRead(
             [FromRoute] string userId,
-            [FromForm] List<string> ids)
+            [FromQuery] string ids)
         {
         }
 
@@ -126,11 +126,11 @@ namespace Jellyfin.Api.Controllers
         /// Endpoint to set notifications as unread.
         /// </summary>
         /// <param name="userId">The userID.</param>
-        /// <param name="ids">The IDs of notifications which should be set as unread.</param>
+        /// <param name="ids">A comma-separated list of the IDs of notifications which should be set as unread.</param>
         [HttpPost("{UserID}/Unread")]
         public void SetUnread(
             [FromRoute] string userId,
-            [FromForm] List<string> ids)
+            [FromQuery] string ids)
         {
         }
     }

+ 3 - 3
Jellyfin.Api/Models/NotificationDtos/NotificationDto.cs

@@ -41,13 +41,13 @@ namespace Jellyfin.Api.Models.NotificationDtos
         public string Description { get; set; } = string.Empty;
 
         /// <summary>
-        /// Gets or sets the notification's URL. Defaults to null.
+        /// Gets or sets the notification's URL. Defaults to an empty string.
         /// </summary>
-        public string? Url { get; set; }
+        public string Url { get; set; } = string.Empty;
 
         /// <summary>
         /// Gets or sets the notification level.
         /// </summary>
-        public NotificationLevel? Level { get; set; }
+        public NotificationLevel Level { get; set; }
     }
 }

+ 21 - 0
Jellyfin.Api/Models/NotificationDtos/NotificationResultDto.cs

@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+
+namespace Jellyfin.Api.Models.NotificationDtos
+{
+    /// <summary>
+    /// A list of notifications with the total record count for pagination.
+    /// </summary>
+    public class NotificationResultDto
+    {
+        /// <summary>
+        /// Gets or sets the current page of notifications.
+        /// </summary>
+        public IReadOnlyList<NotificationDto> Notifications { get; set; } = Array.Empty<NotificationDto>();
+
+        /// <summary>
+        /// Gets or sets the total number of notifications.
+        /// </summary>
+        public int TotalRecordCount { get; set; }
+    }
+}