Skip to content

Commit

Permalink
Remove unused notification endpoints (#8952)
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsvanvelzen committed Dec 27, 2022
1 parent f32d404 commit f2200c9
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 208 deletions.
87 changes: 1 addition & 86 deletions Jellyfin.Api/Controllers/NotificationsController.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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>
Expand All @@ -83,56 +49,5 @@ public IEnumerable<NameIdPair> GetNotificationServices()
{
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();
}
}
}
30 changes: 0 additions & 30 deletions Jellyfin.Api/Models/NotificationDtos/AdminNotificationDto.cs

This file was deleted.

51 changes: 0 additions & 51 deletions Jellyfin.Api/Models/NotificationDtos/NotificationDto.cs

This file was deleted.

21 changes: 0 additions & 21 deletions Jellyfin.Api/Models/NotificationDtos/NotificationResultDto.cs

This file was deleted.

20 changes: 0 additions & 20 deletions Jellyfin.Api/Models/NotificationDtos/NotificationsSummaryDto.cs

This file was deleted.

0 comments on commit f2200c9

Please sign in to comment.