mirror of
https://github.com/jellyfin/jellyfin-plugin-webhook.git
synced 2025-02-21 07:30:45 +00:00
Add Pushbullet client
This commit is contained in:
parent
78f1648a9b
commit
8af1e676a1
@ -2,6 +2,7 @@
|
||||
using Jellyfin.Plugin.Webhook.Destinations.Discord;
|
||||
using Jellyfin.Plugin.Webhook.Destinations.Generic;
|
||||
using Jellyfin.Plugin.Webhook.Destinations.Gotify;
|
||||
using Jellyfin.Plugin.Webhook.Destinations.Pushbullet;
|
||||
using Jellyfin.Plugin.Webhook.Destinations.Pushover;
|
||||
using Jellyfin.Plugin.Webhook.Destinations.Smtp;
|
||||
using MediaBrowser.Model.Plugins;
|
||||
@ -20,9 +21,10 @@ namespace Jellyfin.Plugin.Webhook.Configuration
|
||||
{
|
||||
ServerUrl = string.Empty;
|
||||
DiscordOptions = Array.Empty<DiscordOption>();
|
||||
GotifyOptions = Array.Empty<GotifyOption>();
|
||||
PushoverOptions = Array.Empty<PushoverOption>();
|
||||
GenericOptions = Array.Empty<GenericOption>();
|
||||
GotifyOptions = Array.Empty<GotifyOption>();
|
||||
PushbulletOptions = Array.Empty<PushbulletOption>();
|
||||
PushoverOptions = Array.Empty<PushoverOption>();
|
||||
SmtpOptions = Array.Empty<SmtpOption>();
|
||||
}
|
||||
|
||||
@ -36,21 +38,26 @@ namespace Jellyfin.Plugin.Webhook.Configuration
|
||||
/// </summary>
|
||||
public DiscordOption[] DiscordOptions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the generic options.
|
||||
/// </summary>
|
||||
public GenericOption[] GenericOptions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the gotify options.
|
||||
/// </summary>
|
||||
public GotifyOption[] GotifyOptions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the pushbullet options.
|
||||
/// </summary>
|
||||
public PushbulletOption[] PushbulletOptions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the pushover options.
|
||||
/// </summary>
|
||||
public PushoverOption[] PushoverOptions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the generic options.
|
||||
/// </summary>
|
||||
public GenericOption[] GenericOptions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the smtp options.
|
||||
/// </summary>
|
||||
|
@ -20,15 +20,18 @@
|
||||
<button id="btnAddDiscord" is="emby-button" type="button" class="raised button block">
|
||||
<span>Add Discord Destination</span>
|
||||
</button>
|
||||
<button id="btnAddGeneric" is="emby-button" type="button" class="raised button block">
|
||||
<span>Add Generic Destination</span>
|
||||
</button>
|
||||
<button id="btnAddGotify" is="emby-button" type="button" class="raised button block">
|
||||
<span>Add Gotify Destination</span>
|
||||
</button>
|
||||
<button id="btnAddPushbullet" is="emby-button" type="button" class="raised button block">
|
||||
<span>Add Pushbullet Destination</span>
|
||||
</button>
|
||||
<button id="btnAddPushover" is="emby-button" type="button" class="raised button block">
|
||||
<span>Add Pushover Destination</span>
|
||||
</button>
|
||||
<button id="btnAddGeneric" is="emby-button" type="button" class="raised button block">
|
||||
<span>Add Generic Destination</span>
|
||||
</button>
|
||||
<button id="btnAddSmtp" is="emby-button" type="button" class="raised button block">
|
||||
<span>Add SMTP Destionation</span>
|
||||
</button>
|
||||
@ -239,6 +242,18 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template id="template-pushbullet">
|
||||
<div class="inputContainer">
|
||||
<input is="emby-input" type="text" data-name="txtToken" label="Token:"/>
|
||||
</div>
|
||||
<div class="inputContainer">
|
||||
<input is="emby-input" type="text" data-name="txtDeviceId" label="Device Id:"/>
|
||||
</div>
|
||||
<div class="inputContainer">
|
||||
<input is="emby-input" type="text" data-name="txtChannel" label="Channel:"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
.checkboxContainer {
|
||||
max-width: fit-content;
|
||||
|
@ -184,72 +184,6 @@
|
||||
return config;
|
||||
}
|
||||
},
|
||||
gotify: {
|
||||
btnAdd: document.querySelector("#btnAddGotify"),
|
||||
template: document.querySelector("#template-gotify"),
|
||||
addConfig: function (config) {
|
||||
const template = document.createElement("div");
|
||||
template.dataset.type = "gotify";
|
||||
template.appendChild(Webhook.baseConfig.template.cloneNode(true).content);
|
||||
template.appendChild(Webhook.gotify.template.cloneNode(true).content);
|
||||
|
||||
const baseConfig = Webhook.baseConfig.addConfig(template, "Gotify");
|
||||
Webhook.configurationWrapper.appendChild(baseConfig);
|
||||
|
||||
// Load configuration.
|
||||
Webhook.gotify.setConfig(config, baseConfig);
|
||||
},
|
||||
setConfig: function (config, element) {
|
||||
Webhook.baseConfig.setConfig(config, element);
|
||||
element.querySelector("[data-name=txtToken]").value = config.Token || "";
|
||||
element.querySelector("[data-name=txtPriority]").value = config.Priority || 0;
|
||||
},
|
||||
getConfig: function (e) {
|
||||
const config = Webhook.baseConfig.getConfig(e);
|
||||
config.Token = e.querySelector("[data-name=txtToken]").value || "";
|
||||
config.Priority = e.querySelector("[data-name=txtPriority]").value || 0;
|
||||
return config;
|
||||
}
|
||||
},
|
||||
pushover: {
|
||||
btnAdd: document.querySelector("#btnAddPushover"),
|
||||
template: document.querySelector("#template-pushover"),
|
||||
addConfig: function (config) {
|
||||
const template = document.createElement("div");
|
||||
template.dataset.type = "pushover";
|
||||
template.appendChild(Webhook.baseConfig.template.cloneNode(true).content);
|
||||
template.appendChild(Webhook.pushover.template.cloneNode(true).content);
|
||||
|
||||
const baseConfig = Webhook.baseConfig.addConfig(template, "Pushover");
|
||||
Webhook.configurationWrapper.appendChild(baseConfig);
|
||||
|
||||
// Load configuration
|
||||
Webhook.pushover.setConfig(config, baseConfig);
|
||||
},
|
||||
setConfig: function (config, element) {
|
||||
Webhook.baseConfig.setConfig(config, element);
|
||||
element.querySelector("[data-name=txtToken]").value = config.Token || "";
|
||||
element.querySelector("[data-name=txtUserToken]").value = config.UserToken || "";
|
||||
element.querySelector("[data-name=txtDevice]").value = config.Device || "";
|
||||
element.querySelector("[data-name=txtTitle]").value = config.Title || "";
|
||||
element.querySelector("[data-name=txtMessageUrl]").value = config.MessageUrl || "";
|
||||
element.querySelector("[data-name=txtMessageUrlTitle]").value = config.MessageUrlTitle || "";
|
||||
element.querySelector("[data-name=ddlMessagePriority]").value = config.MessagePriority || "";
|
||||
element.querySelector("[data-name=ddlNotificationSound]").value = config.NotificationSound || "";
|
||||
},
|
||||
getConfig: function (e) {
|
||||
const config = Webhook.baseConfig.getConfig(e);
|
||||
config.Token = e.querySelector("[data-name=txtToken]").value || "";
|
||||
config.UserToken = e.querySelector("[data-name=txtUserToken]").value || "";
|
||||
config.Device = e.querySelector("[data-name=txtDevice]").value || "";
|
||||
config.Title = e.querySelector("[data-name=txtTitle]").value || "";
|
||||
config.MessageUrl = e.querySelector("[data-name=txtMessageUrl]").value || "";
|
||||
config.MessageUrlTitle = e.querySelector("[data-name=txtMessageUrlTitle]").value || "";
|
||||
config.MessagePriority = e.querySelector("[data-name=ddlMessagePriority]").value || 0;
|
||||
config.NotificationSound = e.querySelector("[data-name=ddlNotificationSound]").value || "";
|
||||
return config;
|
||||
}
|
||||
},
|
||||
generic: {
|
||||
btnAdd: document.querySelector("#btnAddGeneric"),
|
||||
template: document.querySelector("#template-generic"),
|
||||
@ -339,6 +273,102 @@
|
||||
element.querySelector("[data-name=field-wrapper]").appendChild(template);
|
||||
}
|
||||
},
|
||||
gotify: {
|
||||
btnAdd: document.querySelector("#btnAddGotify"),
|
||||
template: document.querySelector("#template-gotify"),
|
||||
addConfig: function (config) {
|
||||
const template = document.createElement("div");
|
||||
template.dataset.type = "gotify";
|
||||
template.appendChild(Webhook.baseConfig.template.cloneNode(true).content);
|
||||
template.appendChild(Webhook.gotify.template.cloneNode(true).content);
|
||||
|
||||
const baseConfig = Webhook.baseConfig.addConfig(template, "Gotify");
|
||||
Webhook.configurationWrapper.appendChild(baseConfig);
|
||||
|
||||
// Load configuration.
|
||||
Webhook.gotify.setConfig(config, baseConfig);
|
||||
},
|
||||
setConfig: function (config, element) {
|
||||
Webhook.baseConfig.setConfig(config, element);
|
||||
element.querySelector("[data-name=txtToken]").value = config.Token || "";
|
||||
element.querySelector("[data-name=txtPriority]").value = config.Priority || 0;
|
||||
},
|
||||
getConfig: function (e) {
|
||||
const config = Webhook.baseConfig.getConfig(e);
|
||||
config.Token = e.querySelector("[data-name=txtToken]").value || "";
|
||||
config.Priority = e.querySelector("[data-name=txtPriority]").value || 0;
|
||||
return config;
|
||||
}
|
||||
},
|
||||
pushbullet: {
|
||||
btnAdd: document.querySelector("#btnAddPushbullet"),
|
||||
template: document.querySelector("#template-pushbullet"),
|
||||
addConfig: function (config) {
|
||||
console.log(config);
|
||||
const template = document.createElement("div");
|
||||
template.dataset.type = "pushbullet";
|
||||
template.appendChild(Webhook.baseConfig.template.cloneNode(true).content);
|
||||
template.appendChild(Webhook.pushbullet.template.cloneNode(true).content);
|
||||
|
||||
const baseConfig = Webhook.baseConfig.addConfig(template, "Pushbullet");
|
||||
Webhook.configurationWrapper.appendChild(baseConfig);
|
||||
|
||||
// Load configuration.
|
||||
Webhook.pushbullet.setConfig(config, baseConfig);
|
||||
},
|
||||
setConfig: function (config, element) {
|
||||
Webhook.baseConfig.setConfig(config, element);
|
||||
element.querySelector("[data-name=txtToken]").value = config.Token || "";
|
||||
element.querySelector("[data-name=txtDeviceId]").value = config.DeviceId || "";
|
||||
element.querySelector("[data-name=txtChannel]").value = config.Channel || "";
|
||||
},
|
||||
getConfig: function (e) {
|
||||
const config = Webhook.baseConfig.getConfig(e);
|
||||
config.Token = e.querySelector("[data-name=txtToken]").value || "";
|
||||
config.DeviceId = e.querySelector("[data-name=txtDeviceId]").value || "";
|
||||
config.Channel = e.querySelector("[data-name=txtChannel]").value || "";
|
||||
return config;
|
||||
}
|
||||
},
|
||||
pushover: {
|
||||
btnAdd: document.querySelector("#btnAddPushover"),
|
||||
template: document.querySelector("#template-pushover"),
|
||||
addConfig: function (config) {
|
||||
const template = document.createElement("div");
|
||||
template.dataset.type = "pushover";
|
||||
template.appendChild(Webhook.baseConfig.template.cloneNode(true).content);
|
||||
template.appendChild(Webhook.pushover.template.cloneNode(true).content);
|
||||
|
||||
const baseConfig = Webhook.baseConfig.addConfig(template, "Pushover");
|
||||
Webhook.configurationWrapper.appendChild(baseConfig);
|
||||
|
||||
// Load configuration
|
||||
Webhook.pushover.setConfig(config, baseConfig);
|
||||
},
|
||||
setConfig: function (config, element) {
|
||||
Webhook.baseConfig.setConfig(config, element);
|
||||
element.querySelector("[data-name=txtToken]").value = config.Token || "";
|
||||
element.querySelector("[data-name=txtUserToken]").value = config.UserToken || "";
|
||||
element.querySelector("[data-name=txtDevice]").value = config.Device || "";
|
||||
element.querySelector("[data-name=txtTitle]").value = config.Title || "";
|
||||
element.querySelector("[data-name=txtMessageUrl]").value = config.MessageUrl || "";
|
||||
element.querySelector("[data-name=txtMessageUrlTitle]").value = config.MessageUrlTitle || "";
|
||||
element.querySelector("[data-name=ddlMessagePriority]").value = config.MessagePriority || "";
|
||||
element.querySelector("[data-name=ddlNotificationSound]").value = config.NotificationSound || "";
|
||||
},
|
||||
getConfig: function (e) {
|
||||
const config = Webhook.baseConfig.getConfig(e);
|
||||
config.Token = e.querySelector("[data-name=txtToken]").value || "";
|
||||
config.UserToken = e.querySelector("[data-name=txtUserToken]").value || "";
|
||||
config.Device = e.querySelector("[data-name=txtDevice]").value || "";
|
||||
config.Title = e.querySelector("[data-name=txtTitle]").value || "";
|
||||
config.MessageUrl = e.querySelector("[data-name=txtMessageUrl]").value || "";
|
||||
config.MessageUrlTitle = e.querySelector("[data-name=txtMessageUrlTitle]").value || "";
|
||||
config.MessagePriority = e.querySelector("[data-name=ddlMessagePriority]").value || 0;
|
||||
config.NotificationSound = e.querySelector("[data-name=ddlNotificationSound]").value || "";
|
||||
return config;
|
||||
}
|
||||
},
|
||||
smtp: {
|
||||
btnAdd: document.querySelector("#btnAddSmtp"),
|
||||
template: document.querySelector("#template-smtp"),
|
||||
@ -385,9 +415,10 @@
|
||||
init: function () {
|
||||
// Add click handlers
|
||||
Webhook.discord.btnAdd.addEventListener("click", Webhook.discord.addConfig);
|
||||
Webhook.gotify.btnAdd.addEventListener("click", Webhook.gotify.addConfig);
|
||||
Webhook.pushover.btnAdd.addEventListener("click", Webhook.pushover.addConfig);
|
||||
Webhook.generic.btnAdd.addEventListener("click", Webhook.generic.addConfig);
|
||||
Webhook.gotify.btnAdd.addEventListener("click", Webhook.gotify.addConfig);
|
||||
Webhook.pushbullet.btnAdd.addEventListener("click", Webhook.pushbullet.addConfig);
|
||||
Webhook.pushover.btnAdd.addEventListener("click", Webhook.pushover.addConfig);
|
||||
Webhook.smtp.btnAdd.addEventListener("click", Webhook.smtp.addConfig);
|
||||
document.querySelector("#saveConfig").addEventListener("click", Webhook.saveConfig);
|
||||
|
||||
@ -410,24 +441,30 @@
|
||||
config.DiscordOptions.push(Webhook.discord.getConfig(discordConfigs[i]));
|
||||
}
|
||||
|
||||
config.GenericOptions = [];
|
||||
const genericConfigs = document.querySelectorAll("[data-type=generic]");
|
||||
for (let i = 0; i < genericConfigs.length; i++) {
|
||||
config.GenericOptions.push(Webhook.generic.getConfig(genericConfigs[i]));
|
||||
}
|
||||
|
||||
config.GotifyOptions = [];
|
||||
const gotifyConfigs = document.querySelectorAll("[data-type=gotify]");
|
||||
for (let i = 0; i < gotifyConfigs.length; i++) {
|
||||
config.GotifyOptions.push(Webhook.gotify.getConfig(gotifyConfigs[i]));
|
||||
}
|
||||
|
||||
config.PushbulletOptions = [];
|
||||
const pushbulletConfigs = document.querySelectorAll("[data-type=pushbullet]");
|
||||
for (let i = 0; i < pushbulletConfigs.length; i++) {
|
||||
config.PushbulletOptions.push(Webhook.pushbullet.getConfig(pushbulletConfigs[i]));
|
||||
}
|
||||
|
||||
config.PushoverOptions = [];
|
||||
const pushoverConfigs = document.querySelectorAll("[data-type=pushover]");
|
||||
for (let i = 0; i < pushoverConfigs.length; i++) {
|
||||
config.PushoverOptions.push(Webhook.pushover.getConfig(pushoverConfigs[i]));
|
||||
}
|
||||
|
||||
config.GenericOptions = [];
|
||||
const genericConfigs = document.querySelectorAll("[data-type=generic]");
|
||||
for (let i = 0; i < genericConfigs.length; i++) {
|
||||
config.GenericOptions.push(Webhook.generic.getConfig(genericConfigs[i]));
|
||||
}
|
||||
|
||||
config.SmtpOptions = [];
|
||||
const smtpConfigs = document.querySelectorAll("[data-type=smtp]");
|
||||
for (let i = 0; i < smtpConfigs.length; i++) {
|
||||
@ -445,16 +482,20 @@
|
||||
Webhook.discord.addConfig(config.DiscordOptions[i]);
|
||||
}
|
||||
|
||||
for (let i = 0; i < config.GenericOptions.length; i++) {
|
||||
Webhook.generic.addConfig(config.GenericOptions[i]);
|
||||
}
|
||||
|
||||
for (let i = 0; i < config.GotifyOptions.length; i++) {
|
||||
Webhook.gotify.addConfig(config.GotifyOptions[i]);
|
||||
}
|
||||
|
||||
for (let i = 0; i < config.PushoverOptions.length; i++) {
|
||||
Webhook.pushover.addConfig(config.PushoverOptions[i]);
|
||||
for (let i = 0; i < config.PushbulletOptions.length; i++) {
|
||||
Webhook.pushbullet.addConfig(config.PushbulletOptions[i]);
|
||||
}
|
||||
|
||||
for (let i = 0; i < config.GenericOptions.length; i++) {
|
||||
Webhook.generic.addConfig(config.GenericOptions[i]);
|
||||
for (let i = 0; i < config.PushoverOptions.length; i++) {
|
||||
Webhook.pushover.addConfig(config.PushoverOptions[i]);
|
||||
}
|
||||
|
||||
for (let i = 0; i < config.SmtpOptions.length; i++) {
|
||||
|
@ -0,0 +1,61 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using System.Net.Mime;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Common.Net;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Jellyfin.Plugin.Webhook.Destinations.Pushbullet
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public class PushbulletClient : IWebhookClient<PushbulletOption>
|
||||
{
|
||||
private readonly ILogger<PushbulletClient> _logger;
|
||||
private readonly IHttpClientFactory _httpClientFactory;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PushbulletClient"/> class.
|
||||
/// </summary>
|
||||
/// <param name="logger">Instance of the <see cref="ILogger{PushbulletClient}"/> interface.</param>
|
||||
/// <param name="httpClientFactory">Instance of the <see cref="IHttpClientFactory"/> interface.</param>
|
||||
public PushbulletClient(
|
||||
ILogger<PushbulletClient> logger,
|
||||
IHttpClientFactory httpClientFactory)
|
||||
{
|
||||
_logger = logger;
|
||||
_httpClientFactory = httpClientFactory;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task SendAsync(PushbulletOption options, Dictionary<string, object> data)
|
||||
{
|
||||
try
|
||||
{
|
||||
data["PushbulletToken"] = options.Token;
|
||||
data["PushbulletDeviceId"] = options.DeviceId;
|
||||
data["PushbulletChannel"] = options.Channel;
|
||||
|
||||
var body = options.GetCompiledTemplate()(data);
|
||||
_logger.LogDebug("SendAsync Body: {@Body}", body);
|
||||
|
||||
using var requestOptions = new HttpRequestMessage(HttpMethod.Post, string.IsNullOrEmpty(options.WebhookUri) ? PushbulletOption.ApiUrl : options.WebhookUri);
|
||||
requestOptions.Headers.TryAddWithoutValidation("Access-Token", options.Token);
|
||||
requestOptions.Content = new StringContent(body, Encoding.UTF8, MediaTypeNames.Application.Json);
|
||||
|
||||
using var response = await _httpClientFactory
|
||||
.CreateClient(NamedClient.Default)
|
||||
.SendAsync(requestOptions);
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
var responseStr = await response.Content.ReadAsStringAsync();
|
||||
_logger.LogWarning("Error sending notification: {Response}", responseStr);
|
||||
}
|
||||
}
|
||||
catch (HttpRequestException e)
|
||||
{
|
||||
_logger.LogWarning(e, "Error sending notification");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Jellyfin.Plugin.Webhook.Destinations.Pushbullet
|
||||
{
|
||||
/// <summary>
|
||||
/// Pushbullet specific option.
|
||||
/// </summary>
|
||||
public class PushbulletOption : BaseOption
|
||||
{
|
||||
/// <summary>
|
||||
/// The webhook endpoint.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public const string ApiUrl = "https://api.pushbullet.com/v2/pushes";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the pushbullet token.
|
||||
/// </summary>
|
||||
public string Token { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the device id.
|
||||
/// </summary>
|
||||
public string DeviceId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the channel.
|
||||
/// </summary>
|
||||
public string Channel { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ using Jellyfin.Plugin.Webhook.Destinations;
|
||||
using Jellyfin.Plugin.Webhook.Destinations.Discord;
|
||||
using Jellyfin.Plugin.Webhook.Destinations.Generic;
|
||||
using Jellyfin.Plugin.Webhook.Destinations.Gotify;
|
||||
using Jellyfin.Plugin.Webhook.Destinations.Pushbullet;
|
||||
using Jellyfin.Plugin.Webhook.Destinations.Pushover;
|
||||
using Jellyfin.Plugin.Webhook.Destinations.Smtp;
|
||||
using Jellyfin.Plugin.Webhook.Notifiers;
|
||||
@ -34,6 +35,7 @@ namespace Jellyfin.Plugin.Webhook
|
||||
serviceCollection.AddScoped<IWebhookClient<DiscordOption>, DiscordClient>();
|
||||
serviceCollection.AddScoped<IWebhookClient<GenericOption>, GenericClient>();
|
||||
serviceCollection.AddScoped<IWebhookClient<GotifyOption>, GotifyClient>();
|
||||
serviceCollection.AddScoped<IWebhookClient<PushbulletOption>, PushbulletClient>();
|
||||
serviceCollection.AddScoped<IWebhookClient<PushoverOption>, PushoverClient>();
|
||||
serviceCollection.AddScoped<IWebhookClient<SmtpOption>, SmtpClient>();
|
||||
|
||||
|
@ -1,14 +1,13 @@
|
||||
/*
|
||||
Required Headers:
|
||||
Content-Type: application/json
|
||||
Access-Token: ${your-access-token}
|
||||
*/
|
||||
|
||||
|
||||
{
|
||||
{
|
||||
"type": "link",
|
||||
"title": "{{{Name}}} added to {{{ServerName}}}",
|
||||
"url": "{{ServerUrl}}/web/index.html#!/details?id={{ItemId}}&serverId={{ServerId}}",
|
||||
{{#if_exist PushbulletDeviceId}}
|
||||
"device_iden ": "{{PushbulletDeviceId}}",
|
||||
{{/if_exist}}
|
||||
{{#if_exist PushbulletChannel}}
|
||||
"channel_tag": "{{PushbulletChannel}}",
|
||||
{{/if_exist}}
|
||||
{{#if_equals ItemType 'Season'}}
|
||||
"body": "{{{SeriesName}}} {{{Name}}} has been added to {{{ServerName}}}"
|
||||
{{else}}
|
||||
|
@ -7,6 +7,7 @@ using Jellyfin.Plugin.Webhook.Destinations;
|
||||
using Jellyfin.Plugin.Webhook.Destinations.Discord;
|
||||
using Jellyfin.Plugin.Webhook.Destinations.Generic;
|
||||
using Jellyfin.Plugin.Webhook.Destinations.Gotify;
|
||||
using Jellyfin.Plugin.Webhook.Destinations.Pushbullet;
|
||||
using Jellyfin.Plugin.Webhook.Destinations.Pushover;
|
||||
using Jellyfin.Plugin.Webhook.Destinations.Smtp;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
@ -21,9 +22,10 @@ namespace Jellyfin.Plugin.Webhook
|
||||
{
|
||||
private readonly ILogger<WebhookSender> _logger;
|
||||
private readonly IWebhookClient<DiscordOption> _discordClient;
|
||||
private readonly IWebhookClient<GotifyOption> _gotifyClient;
|
||||
private readonly IWebhookClient<PushoverOption> _pushoverClient;
|
||||
private readonly IWebhookClient<GenericOption> _genericClient;
|
||||
private readonly IWebhookClient<GotifyOption> _gotifyClient;
|
||||
private readonly IWebhookClient<PushbulletOption> _pushbulletClient;
|
||||
private readonly IWebhookClient<PushoverOption> _pushoverClient;
|
||||
private readonly IWebhookClient<SmtpOption> _smtpClient;
|
||||
|
||||
/// <summary>
|
||||
@ -31,23 +33,26 @@ namespace Jellyfin.Plugin.Webhook
|
||||
/// </summary>
|
||||
/// <param name="logger">Instance of the <see cref="ILogger{WebhookSender}"/> interface.</param>
|
||||
/// <param name="discordClient">Instance of <see cref="IWebhookClient{DiscordOption}"/>.</param>
|
||||
/// /// <param name="genericClient">Instance of the <see cref="IWebhookClient{GenericOption}"/>.</param>
|
||||
/// <param name="gotifyClient">Instance of <see cref="IWebhookClient{GotifyOption}"/>.</param>
|
||||
/// <param name="pushbulletClient">Instance of the <see cref="IWebhookClient{PushbulletOption}"/>.</param>
|
||||
/// <param name="pushoverClient">Instance of the <see cref="IWebhookClient{PushoverOption}"/>.</param>
|
||||
/// <param name="genericClient">Instance of the <see cref="IWebhookClient{GenericOption}"/>.</param>
|
||||
/// <param name="smtpClient">Instance of the <see cref="IWebhookClient{SmtpOption}"/>.</param>
|
||||
public WebhookSender(
|
||||
ILogger<WebhookSender> logger,
|
||||
IWebhookClient<DiscordOption> discordClient,
|
||||
IWebhookClient<GotifyOption> gotifyClient,
|
||||
IWebhookClient<PushoverOption> pushoverClient,
|
||||
IWebhookClient<GenericOption> genericClient,
|
||||
IWebhookClient<GotifyOption> gotifyClient,
|
||||
IWebhookClient<PushbulletOption> pushbulletClient,
|
||||
IWebhookClient<PushoverOption> pushoverClient,
|
||||
IWebhookClient<SmtpOption> smtpClient)
|
||||
{
|
||||
_logger = logger;
|
||||
_discordClient = discordClient;
|
||||
_gotifyClient = gotifyClient;
|
||||
_pushoverClient = pushoverClient;
|
||||
_genericClient = genericClient;
|
||||
_gotifyClient = gotifyClient;
|
||||
_pushbulletClient = pushbulletClient;
|
||||
_pushoverClient = pushoverClient;
|
||||
_smtpClient = smtpClient;
|
||||
}
|
||||
|
||||
@ -63,21 +68,26 @@ namespace Jellyfin.Plugin.Webhook
|
||||
await SendNotification(_discordClient, option, itemData, itemType);
|
||||
}
|
||||
|
||||
foreach (var option in Configuration.GenericOptions.Where(o => o.NotificationTypes.Contains(notificationType)))
|
||||
{
|
||||
await SendNotification(_genericClient, option, itemData, itemType);
|
||||
}
|
||||
|
||||
foreach (var option in Configuration.GotifyOptions.Where(o => o.NotificationTypes.Contains(notificationType)))
|
||||
{
|
||||
await SendNotification(_gotifyClient, option, itemData, itemType);
|
||||
}
|
||||
|
||||
foreach (var option in Configuration.PushbulletOptions.Where(o => o.NotificationTypes.Contains(notificationType)))
|
||||
{
|
||||
await SendNotification(_pushbulletClient, option, itemData, itemType);
|
||||
}
|
||||
|
||||
foreach (var option in Configuration.PushoverOptions.Where(o => o.NotificationTypes.Contains(notificationType)))
|
||||
{
|
||||
await SendNotification(_pushoverClient, option, itemData, itemType);
|
||||
}
|
||||
|
||||
foreach (var option in Configuration.GenericOptions.Where(o => o.NotificationTypes.Contains(notificationType)))
|
||||
{
|
||||
await SendNotification(_genericClient, option, itemData, itemType);
|
||||
}
|
||||
|
||||
foreach (var option in Configuration.SmtpOptions.Where(o => o.NotificationTypes.Contains(notificationType)))
|
||||
{
|
||||
await SendNotification(_smtpClient, option, itemData, itemType);
|
||||
|
Loading…
x
Reference in New Issue
Block a user