mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-04-24 05:57:20 -04:00
Remove unused notification endpoints (#8952)
This commit is contained in:
parent
f32d4040f2
commit
f2200c97cb
5 changed files with 1 additions and 208 deletions
|
@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="NotificationsController" /> class.
|
||||
/// </summary>
|
||||
/// <param name="notificationManager">The notification manager.</param>
|
||||
/// <param name="userManager">The user manager.</param>
|
||||
public NotificationsController(INotificationManager notificationManager, IUserManager userManager)
|
||||
public NotificationsController(INotificationManager notificationManager)
|
||||
{
|
||||
_notificationManager = notificationManager;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a user's notifications.
|
||||
/// </summary>
|
||||
/// <response code="200">Notifications returned.</response>
|
||||
/// <returns>An <see cref="OkResult"/> containing a list of notifications.</returns>
|
||||
[HttpGet("{userId}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
public ActionResult<NotificationResultDto> GetNotifications()
|
||||
{
|
||||
return new NotificationResultDto();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a user's notification summary.
|
||||
/// </summary>
|
||||
/// <response code="200">Summary of user's notifications returned.</response>
|
||||
/// <returns>An <cref see="OkResult"/> containing a summary of the users notifications.</returns>
|
||||
[HttpGet("{userId}/Summary")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
public ActionResult<NotificationsSummaryDto> GetNotificationsSummary()
|
||||
{
|
||||
return new NotificationsSummaryDto();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -83,56 +49,5 @@ namespace Jellyfin.Api.Controllers
|
|||
{
|
||||
return _notificationManager.GetNotificationServices();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends a notification to all admins.
|
||||
/// </summary>
|
||||
/// <param name="notificationDto">The notification request.</param>
|
||||
/// <response code="204">Notification sent.</response>
|
||||
/// <returns>A <cref see="NoContentResult"/>.</returns>
|
||||
[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();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets notifications as read.
|
||||
/// </summary>
|
||||
/// <response code="204">Notifications set as read.</response>
|
||||
/// <returns>A <cref see="NoContentResult"/>.</returns>
|
||||
[HttpPost("{userId}/Read")]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
public ActionResult SetRead()
|
||||
{
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets notifications as unread.
|
||||
/// </summary>
|
||||
/// <response code="204">Notifications set as unread.</response>
|
||||
/// <returns>A <cref see="NoContentResult"/>.</returns>
|
||||
[HttpPost("{userId}/Unread")]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
public ActionResult SetUnread()
|
||||
{
|
||||
return NoContent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
using MediaBrowser.Model.Notifications;
|
||||
|
||||
namespace Jellyfin.Api.Models.NotificationDtos
|
||||
{
|
||||
/// <summary>
|
||||
/// The admin notification dto.
|
||||
/// </summary>
|
||||
public class AdminNotificationDto
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the notification name.
|
||||
/// </summary>
|
||||
public string? Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the notification description.
|
||||
/// </summary>
|
||||
public string? Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the notification level.
|
||||
/// </summary>
|
||||
public NotificationLevel? NotificationLevel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the notification url.
|
||||
/// </summary>
|
||||
public string? Url { get; set; }
|
||||
}
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
using System;
|
||||
using MediaBrowser.Model.Notifications;
|
||||
|
||||
namespace Jellyfin.Api.Models.NotificationDtos
|
||||
{
|
||||
/// <summary>
|
||||
/// The notification DTO.
|
||||
/// </summary>
|
||||
public class NotificationDto
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the notification ID. Defaults to an empty string.
|
||||
/// </summary>
|
||||
public string Id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the notification's user ID. Defaults to an empty string.
|
||||
/// </summary>
|
||||
public string UserId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the notification date.
|
||||
/// </summary>
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the notification has been read. Defaults to false.
|
||||
/// </summary>
|
||||
public bool IsRead { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the notification's name. Defaults to an empty string.
|
||||
/// </summary>
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the notification's description. Defaults to an empty string.
|
||||
/// </summary>
|
||||
public string Description { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the notification's URL. Defaults to an empty string.
|
||||
/// </summary>
|
||||
public string Url { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the notification level.
|
||||
/// </summary>
|
||||
public NotificationLevel Level { get; set; }
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
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; }
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
using MediaBrowser.Model.Notifications;
|
||||
|
||||
namespace Jellyfin.Api.Models.NotificationDtos
|
||||
{
|
||||
/// <summary>
|
||||
/// The notification summary DTO.
|
||||
/// </summary>
|
||||
public class NotificationsSummaryDto
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the number of unread notifications.
|
||||
/// </summary>
|
||||
public int UnreadCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the maximum unread notification level.
|
||||
/// </summary>
|
||||
public NotificationLevel? MaxUnreadNotificationLevel { get; set; }
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue