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

Commit

Permalink
Merge pull request #19 from jellyfin/10.7
Browse files Browse the repository at this point in the history
Target 10.7
  • Loading branch information
oddstr13 authored Dec 4, 2020
2 parents 309a334 + 8c4be8c commit d825c7c
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 59 deletions.
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();
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<FileVersion>8.0.0.0</FileVersion>
<TargetFramework>net5.0</TargetFramework>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<FileVersion>9.0.0.0</FileVersion>
</PropertyGroup>

<ItemGroup>
Expand All @@ -12,7 +12,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="MailKit" Version="2.8.0" />
<PackageReference Include="MailKit" Version="2.10.0" />
<PackageReference Include="Jellyfin.Data" Version="10.*-*" />
<PackageReference Include="Jellyfin.Controller" Version="10.*-*" />
<PackageReference Include="Jellyfin.Data" Version="10.*-*"/>
<PackageReference Include="Jellyfin.Controller" Version="10.*-*"/>
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
Expand Down
5 changes: 3 additions & 2 deletions build.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
---
name: "Email"
guid: "cfa0f7f4-4155-4d71-849b-d6598dc4c5bb"
version: "8.0.0.0"
targetAbi: "10.6.0.0"
version: "9.0.0.0"
targetAbi: "10.7.0.0"
framework: "net5.0"
owner: "jellyfin"
overview: "Send SMTP email notifications"
description: "Send SMTP email notifications"
Expand Down

0 comments on commit d825c7c

Please sign in to comment.