Skip to content
This repository was archived by the owner on Jun 14, 2022. It is now read-only.

Commit d825c7c

Browse files
authored
Merge pull request #19 from jellyfin/10.7
Target 10.7
2 parents 309a334 + 8c4be8c commit d825c7c

File tree

4 files changed

+69
-59
lines changed

4 files changed

+69
-59
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
using System;
2+
using System.ComponentModel.DataAnnotations;
3+
using System.Net.Mime;
4+
using System.Threading;
5+
using System.Threading.Tasks;
6+
using MediaBrowser.Controller.Library;
7+
using MediaBrowser.Controller.Notifications;
8+
using Microsoft.AspNetCore.Authorization;
9+
using Microsoft.AspNetCore.Http;
10+
using Microsoft.AspNetCore.Mvc;
11+
using Microsoft.Extensions.Logging;
12+
13+
namespace MediaBrowser.Plugins.SmtpNotifications.Api
14+
{
15+
[ApiController]
16+
[Authorize(Policy = "RequiresElevation")]
17+
[Produces(MediaTypeNames.Application.Json)]
18+
[Route("Notification/SMTP")]
19+
public class EmailNotificationController : ControllerBase
20+
{
21+
private readonly IUserManager _userManager;
22+
private readonly ILogger<Notifier> _notifierLogger;
23+
24+
/// <summary>
25+
/// Creates a new instance of the <see cref="EmailNotificationController"/>.
26+
/// </summary>
27+
/// <param name="userManager">Instance of the <see cref="IUserManager"/> interface.</param>
28+
/// <param name="notifierLogger">Instance of the <see cref="ILogger{Notifier}"/> interface.</param>
29+
public EmailNotificationController(
30+
IUserManager userManager,
31+
ILogger<Notifier> notifierLogger)
32+
{
33+
_userManager = userManager;
34+
_notifierLogger = notifierLogger;
35+
}
36+
37+
/// <summary>
38+
/// Tests the configured notification.
39+
/// </summary>
40+
/// <param name="userId">User to test notification for.</param>
41+
/// <response code="204">Notification tested successfully.</response>
42+
/// <returns>A <see cref="NoContentResult"/></returns>
43+
[HttpPost("Test/{userId}")]
44+
[ProducesResponseType(StatusCodes.Status204NoContent)]
45+
public async Task<ActionResult> TestNotification([FromRoute, Required] Guid userId)
46+
{
47+
await new Notifier(_notifierLogger).SendNotification(
48+
new UserNotification
49+
{
50+
Date = DateTime.UtcNow,
51+
Description = "This is a test notification from Jellyfin Server",
52+
Level = Model.Notifications.NotificationLevel.Normal,
53+
Name = "Test Notification",
54+
User = _userManager.GetUserById(userId)
55+
}, CancellationToken.None).ConfigureAwait(false);
56+
57+
return NoContent();
58+
}
59+
}
60+
}

MediaBrowser.Plugins.SmtpNotifications/Api/SmtpNotificationsController.cs

Lines changed: 0 additions & 53 deletions
This file was deleted.

MediaBrowser.Plugins.SmtpNotifications/MediaBrowser.Plugins.SmtpNotifications.csproj

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netstandard2.1</TargetFramework>
5-
<AssemblyVersion>8.0.0.0</AssemblyVersion>
6-
<FileVersion>8.0.0.0</FileVersion>
4+
<TargetFramework>net5.0</TargetFramework>
5+
<AssemblyVersion>9.0.0.0</AssemblyVersion>
6+
<FileVersion>9.0.0.0</FileVersion>
77
</PropertyGroup>
88

99
<ItemGroup>
@@ -12,7 +12,9 @@
1212
</ItemGroup>
1313

1414
<ItemGroup>
15-
<PackageReference Include="MailKit" Version="2.8.0" />
15+
<PackageReference Include="MailKit" Version="2.10.0" />
16+
<PackageReference Include="Jellyfin.Data" Version="10.*-*" />
17+
<PackageReference Include="Jellyfin.Controller" Version="10.*-*" />
1618
<PackageReference Include="Jellyfin.Data" Version="10.*-*"/>
1719
<PackageReference Include="Jellyfin.Controller" Version="10.*-*"/>
1820
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />

build.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
---
22
name: "Email"
33
guid: "cfa0f7f4-4155-4d71-849b-d6598dc4c5bb"
4-
version: "8.0.0.0"
5-
targetAbi: "10.6.0.0"
4+
version: "9.0.0.0"
5+
targetAbi: "10.7.0.0"
6+
framework: "net5.0"
67
owner: "jellyfin"
78
overview: "Send SMTP email notifications"
89
description: "Send SMTP email notifications"

0 commit comments

Comments
 (0)