forked from MindFlavor/Jellyfin.Plugins.Telegram
-
Notifications
You must be signed in to change notification settings - Fork 0
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 MindFlavor#6 from MindFlavor/support_10.7.0
Support for Jellyfin 10.7.0
- Loading branch information
Showing
6 changed files
with
106 additions
and
97 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
53 changes: 53 additions & 0 deletions
53
Jellyfin.Plugins.Telegram/Api/TelegramNotificationsController.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,53 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Net.Mime; | ||
using System.Threading.Tasks; | ||
using Jellyfin.Plugins.Telegram.Configuration; | ||
using MediaBrowser.Common.Net; | ||
using MediaBrowser.Model.Serialization; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.Extensions.Logging; | ||
using System.Net.Http; | ||
|
||
namespace Jellyfin.Plugins.Telegram.Api | ||
{ | ||
[ApiController] | ||
[Route("Notification/Telegram")] | ||
[Produces(MediaTypeNames.Application.Json)] | ||
public class TelegramNotificationsController : ControllerBase | ||
{ | ||
private readonly IHttpClientFactory _httpClientFactory; | ||
private readonly IJsonSerializer _jsonSerializer; | ||
private readonly ILogger _logger; | ||
|
||
public TelegramNotificationsController(IHttpClientFactory httpClientFactory, IJsonSerializer jsonSerializer, ILoggerFactory loggerFactory) | ||
{ | ||
_httpClientFactory = httpClientFactory; | ||
_jsonSerializer = jsonSerializer; | ||
_logger = loggerFactory.CreateLogger<TelegramNotificationsController>(); | ||
} | ||
|
||
private static TelegramOptions GetOptions(string userId) | ||
{ | ||
return Plugin.Instance.Configuration.Options | ||
.FirstOrDefault(u => string.Equals(u.UserId, userId, | ||
StringComparison.OrdinalIgnoreCase)); | ||
} | ||
|
||
[HttpPost("Test/{userId}")] | ||
[ProducesResponseType(Microsoft.AspNetCore.Http.StatusCodes.Status204NoContent)] | ||
public async Task<ActionResult> PostAsync([FromRoute] string userId) | ||
{ | ||
var options = GetOptions(userId); | ||
|
||
await Notifier.SendNotification( | ||
_httpClientFactory, | ||
options.Token, options.ChatId, options.SilentNotificationEnabled, | ||
"This is a test notification from Jellyfin" | ||
); | ||
|
||
return NoContent(); | ||
} | ||
} | ||
} |
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
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