diff --git a/Jellyfin.Api/Controllers/NotificationsController.cs b/Jellyfin.Api/Controllers/NotificationsController.cs index 420630cdf4..a285564760 100644 --- a/Jellyfin.Api/Controllers/NotificationsController.cs +++ b/Jellyfin.Api/Controllers/NotificationsController.cs @@ -1,12 +1,5 @@ -using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Linq; -using System.Threading; using Jellyfin.Api.Constants; -using Jellyfin.Api.Models.NotificationDtos; -using Jellyfin.Data.Enums; -using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Notifications; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Notifications; @@ -23,41 +16,14 @@ namespace Jellyfin.Api.Controllers public class NotificationsController : BaseJellyfinApiController { private readonly INotificationManager _notificationManager; - private readonly IUserManager _userManager; /// /// Initializes a new instance of the class. /// /// The notification manager. - /// The user manager. - public NotificationsController(INotificationManager notificationManager, IUserManager userManager) + public NotificationsController(INotificationManager notificationManager) { _notificationManager = notificationManager; - _userManager = userManager; - } - - /// - /// Gets a user's notifications. - /// - /// Notifications returned. - /// An containing a list of notifications. - [HttpGet("{userId}")] - [ProducesResponseType(StatusCodes.Status200OK)] - public ActionResult GetNotifications() - { - return new NotificationResultDto(); - } - - /// - /// Gets a user's notification summary. - /// - /// Summary of user's notifications returned. - /// An containing a summary of the users notifications. - [HttpGet("{userId}/Summary")] - [ProducesResponseType(StatusCodes.Status200OK)] - public ActionResult GetNotificationsSummary() - { - return new NotificationsSummaryDto(); } /// @@ -83,56 +49,5 @@ namespace Jellyfin.Api.Controllers { return _notificationManager.GetNotificationServices(); } - - /// - /// Sends a notification to all admins. - /// - /// The notification request. - /// Notification sent. - /// A . - [HttpPost("Admin")] - [ProducesResponseType(StatusCodes.Status204NoContent)] - public ActionResult CreateAdminNotification([FromBody, Required] AdminNotificationDto notificationDto) - { - var notification = new NotificationRequest - { - Name = notificationDto.Name, - Description = notificationDto.Description, - Url = notificationDto.Url, - Level = notificationDto.NotificationLevel ?? NotificationLevel.Normal, - UserIds = _userManager.Users - .Where(user => user.HasPermission(PermissionKind.IsAdministrator)) - .Select(user => user.Id) - .ToArray(), - Date = DateTime.UtcNow, - }; - - _notificationManager.SendNotification(notification, CancellationToken.None); - return NoContent(); - } - - /// - /// Sets notifications as read. - /// - /// Notifications set as read. - /// A . - [HttpPost("{userId}/Read")] - [ProducesResponseType(StatusCodes.Status204NoContent)] - public ActionResult SetRead() - { - return NoContent(); - } - - /// - /// Sets notifications as unread. - /// - /// Notifications set as unread. - /// A . - [HttpPost("{userId}/Unread")] - [ProducesResponseType(StatusCodes.Status204NoContent)] - public ActionResult SetUnread() - { - return NoContent(); - } } } diff --git a/Jellyfin.Api/Models/NotificationDtos/AdminNotificationDto.cs b/Jellyfin.Api/Models/NotificationDtos/AdminNotificationDto.cs deleted file mode 100644 index 2c3a6282f2..0000000000 --- a/Jellyfin.Api/Models/NotificationDtos/AdminNotificationDto.cs +++ /dev/null @@ -1,30 +0,0 @@ -using MediaBrowser.Model.Notifications; - -namespace Jellyfin.Api.Models.NotificationDtos -{ - /// - /// The admin notification dto. - /// - public class AdminNotificationDto - { - /// - /// Gets or sets the notification name. - /// - public string? Name { get; set; } - - /// - /// Gets or sets the notification description. - /// - public string? Description { get; set; } - - /// - /// Gets or sets the notification level. - /// - public NotificationLevel? NotificationLevel { get; set; } - - /// - /// Gets or sets the notification url. - /// - public string? Url { get; set; } - } -} diff --git a/Jellyfin.Api/Models/NotificationDtos/NotificationDto.cs b/Jellyfin.Api/Models/NotificationDtos/NotificationDto.cs deleted file mode 100644 index af5239ec2b..0000000000 --- a/Jellyfin.Api/Models/NotificationDtos/NotificationDto.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using MediaBrowser.Model.Notifications; - -namespace Jellyfin.Api.Models.NotificationDtos -{ - /// - /// The notification DTO. - /// - public class NotificationDto - { - /// - /// Gets or sets the notification ID. Defaults to an empty string. - /// - public string Id { get; set; } = string.Empty; - - /// - /// Gets or sets the notification's user ID. Defaults to an empty string. - /// - public string UserId { get; set; } = string.Empty; - - /// - /// Gets or sets the notification date. - /// - public DateTime Date { get; set; } - - /// - /// Gets or sets a value indicating whether the notification has been read. Defaults to false. - /// - public bool IsRead { get; set; } = false; - - /// - /// Gets or sets the notification's name. Defaults to an empty string. - /// - public string Name { get; set; } = string.Empty; - - /// - /// Gets or sets the notification's description. Defaults to an empty string. - /// - public string Description { get; set; } = string.Empty; - - /// - /// Gets or sets the notification's URL. Defaults to an empty string. - /// - public string Url { get; set; } = string.Empty; - - /// - /// Gets or sets the notification level. - /// - public NotificationLevel Level { get; set; } - } -} diff --git a/Jellyfin.Api/Models/NotificationDtos/NotificationResultDto.cs b/Jellyfin.Api/Models/NotificationDtos/NotificationResultDto.cs deleted file mode 100644 index 64e92bd83a..0000000000 --- a/Jellyfin.Api/Models/NotificationDtos/NotificationResultDto.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace Jellyfin.Api.Models.NotificationDtos -{ - /// - /// A list of notifications with the total record count for pagination. - /// - public class NotificationResultDto - { - /// - /// Gets or sets the current page of notifications. - /// - public IReadOnlyList Notifications { get; set; } = Array.Empty(); - - /// - /// Gets or sets the total number of notifications. - /// - public int TotalRecordCount { get; set; } - } -} diff --git a/Jellyfin.Api/Models/NotificationDtos/NotificationsSummaryDto.cs b/Jellyfin.Api/Models/NotificationDtos/NotificationsSummaryDto.cs deleted file mode 100644 index 0568dea666..0000000000 --- a/Jellyfin.Api/Models/NotificationDtos/NotificationsSummaryDto.cs +++ /dev/null @@ -1,20 +0,0 @@ -using MediaBrowser.Model.Notifications; - -namespace Jellyfin.Api.Models.NotificationDtos -{ - /// - /// The notification summary DTO. - /// - public class NotificationsSummaryDto - { - /// - /// Gets or sets the number of unread notifications. - /// - public int UnreadCount { get; set; } - - /// - /// Gets or sets the maximum unread notification level. - /// - public NotificationLevel? MaxUnreadNotificationLevel { get; set; } - } -}