NotificationsController.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using System.Collections.Generic;
  2. using Jellyfin.Api.Constants;
  3. using MediaBrowser.Controller.Notifications;
  4. using MediaBrowser.Model.Dto;
  5. using MediaBrowser.Model.Notifications;
  6. using Microsoft.AspNetCore.Authorization;
  7. using Microsoft.AspNetCore.Http;
  8. using Microsoft.AspNetCore.Mvc;
  9. namespace Jellyfin.Api.Controllers
  10. {
  11. /// <summary>
  12. /// The notification controller.
  13. /// </summary>
  14. [Authorize(Policy = Policies.DefaultAuthorization)]
  15. public class NotificationsController : BaseJellyfinApiController
  16. {
  17. private readonly INotificationManager _notificationManager;
  18. /// <summary>
  19. /// Initializes a new instance of the <see cref="NotificationsController" /> class.
  20. /// </summary>
  21. /// <param name="notificationManager">The notification manager.</param>
  22. public NotificationsController(INotificationManager notificationManager)
  23. {
  24. _notificationManager = notificationManager;
  25. }
  26. /// <summary>
  27. /// Gets notification types.
  28. /// </summary>
  29. /// <response code="200">All notification types returned.</response>
  30. /// <returns>An <cref see="OkResult"/> containing a list of all notification types.</returns>
  31. [HttpGet("Types")]
  32. [ProducesResponseType(StatusCodes.Status200OK)]
  33. public IEnumerable<NotificationTypeInfo> GetNotificationTypes()
  34. {
  35. return _notificationManager.GetNotificationTypes();
  36. }
  37. /// <summary>
  38. /// Gets notification services.
  39. /// </summary>
  40. /// <response code="200">All notification services returned.</response>
  41. /// <returns>An <cref see="OkResult"/> containing a list of all notification services.</returns>
  42. [HttpGet("Services")]
  43. [ProducesResponseType(StatusCodes.Status200OK)]
  44. public IEnumerable<NameIdPair> GetNotificationServices()
  45. {
  46. return _notificationManager.GetNotificationServices();
  47. }
  48. }
  49. }