This repository has been archived by the owner on Jun 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from jellyfin/10.7
Target 10.7
- Loading branch information
Showing
4 changed files
with
69 additions
and
59 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
MediaBrowser.Plugins.SmtpNotifications/Api/EmailNotificationController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
using System; | ||
using System.ComponentModel.DataAnnotations; | ||
using System.Net.Mime; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using MediaBrowser.Controller.Library; | ||
using MediaBrowser.Controller.Notifications; | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace MediaBrowser.Plugins.SmtpNotifications.Api | ||
{ | ||
[ApiController] | ||
[Authorize(Policy = "RequiresElevation")] | ||
[Produces(MediaTypeNames.Application.Json)] | ||
[Route("Notification/SMTP")] | ||
public class EmailNotificationController : ControllerBase | ||
{ | ||
private readonly IUserManager _userManager; | ||
private readonly ILogger<Notifier> _notifierLogger; | ||
|
||
/// <summary> | ||
/// Creates a new instance of the <see cref="EmailNotificationController"/>. | ||
/// </summary> | ||
/// <param name="userManager">Instance of the <see cref="IUserManager"/> interface.</param> | ||
/// <param name="notifierLogger">Instance of the <see cref="ILogger{Notifier}"/> interface.</param> | ||
public EmailNotificationController( | ||
IUserManager userManager, | ||
ILogger<Notifier> notifierLogger) | ||
{ | ||
_userManager = userManager; | ||
_notifierLogger = notifierLogger; | ||
} | ||
|
||
/// <summary> | ||
/// Tests the configured notification. | ||
/// </summary> | ||
/// <param name="userId">User to test notification for.</param> | ||
/// <response code="204">Notification tested successfully.</response> | ||
/// <returns>A <see cref="NoContentResult"/></returns> | ||
[HttpPost("Test/{userId}")] | ||
[ProducesResponseType(StatusCodes.Status204NoContent)] | ||
public async Task<ActionResult> TestNotification([FromRoute, Required] Guid userId) | ||
{ | ||
await new Notifier(_notifierLogger).SendNotification( | ||
new UserNotification | ||
{ | ||
Date = DateTime.UtcNow, | ||
Description = "This is a test notification from Jellyfin Server", | ||
Level = Model.Notifications.NotificationLevel.Normal, | ||
Name = "Test Notification", | ||
User = _userManager.GetUserById(userId) | ||
}, CancellationToken.None).ConfigureAwait(false); | ||
|
||
return NoContent(); | ||
} | ||
} | ||
} |
53 changes: 0 additions & 53 deletions
53
MediaBrowser.Plugins.SmtpNotifications/Api/SmtpNotificationsController.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters