From 20bf14b6a2488bde7220cb29cddb08a1aa845ff5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20F=C3=A4th?= Date: Mon, 9 Sep 2019 11:00:15 +0200 Subject: [PATCH 01/14] Fix for 10.3.7 --- Pushbullet/Notifier.cs | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/Pushbullet/Notifier.cs b/Pushbullet/Notifier.cs index 886362d..e49278c 100644 --- a/Pushbullet/Notifier.cs +++ b/Pushbullet/Notifier.cs @@ -1,9 +1,10 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Text; using MediaBrowser.Common.Net; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Notifications; using Microsoft.Extensions.Logging; +using MediaBrowser.Model.Serialization; using Pushbullet.Configuration; using System; using System.Linq; @@ -16,11 +17,13 @@ public class Notifier : INotificationService { private readonly ILogger _logger; private readonly IHttpClient _httpClient; + private readonly IJsonSerializer _jsonSerializer; - public Notifier(ILogger logger, IHttpClient httpClient) + public Notifier(ILogger logger, IHttpClient httpClient, IJsonSerializer jsonSerializer) { _logger = logger; _httpClient = httpClient; + _jsonSerializer = jsonSerializer; } public bool IsEnabledForUser(User user) @@ -54,20 +57,23 @@ public async Task SendNotification(UserNotification request, CancellationToken c }; _logger.LogDebug("Pushbullet to Token : {0} - {1} - {2}", options.Token, options.DeviceId, request.Description); - var _httpRequest = new HttpRequestOptions(); + string authInfo = options.Token; authInfo = Convert.ToBase64String(Encoding.UTF8.GetBytes(authInfo)); - _httpRequest.RequestHeaders["Authorization"] = "Basic " + authInfo; - - _httpRequest.Url = "https://api.pushbullet.com/v2/pushes"; - - _httpRequest.SetPostData(parameters); - - using (await _httpClient.Post(_httpRequest).ConfigureAwait(false)) - { - - } + var requestOptions = new HttpRequestOptions + { + Url = "https://api.pushbullet.com/v2/pushes", + RequestContent = _jsonSerializer.SerializeToString(parameters), + BufferContent = false, + RequestContentType = "application/json", + LogErrorResponseBody = true, + LogRequest = true, + DecompressionMethod = CompressionMethod.None, + EnableKeepAlive = false + }; + requestOptions.RequestHeaders["Authorization"] = "Basic " + authInfo; + await _httpClient.Post(requestOptions).ConfigureAwait(false); } private bool IsValid(PushbulletOptions options) From 5a8043a2278bd15b22abfa707446a84adc9044d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20F=C3=A4th?= Date: Mon, 9 Sep 2019 11:02:08 +0200 Subject: [PATCH 02/14] Fix for 10.3.7 --- Pushbullet/Api/ServerApiEntryPoints.cs | 28 ++++++++++++++++---------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/Pushbullet/Api/ServerApiEntryPoints.cs b/Pushbullet/Api/ServerApiEntryPoints.cs index 69f65ce..bbe453a 100644 --- a/Pushbullet/Api/ServerApiEntryPoints.cs +++ b/Pushbullet/Api/ServerApiEntryPoints.cs @@ -6,6 +6,7 @@ using System.Text; using MediaBrowser.Common.Net; using MediaBrowser.Controller.Net; +using MediaBrowser.Model.Serialization; using Microsoft.Extensions.Logging; using MediaBrowser.Model.Services; using Pushbullet.Configuration; @@ -24,11 +25,13 @@ public class TestNotification : IReturnVoid class ServerApiEndpoints : IService { private readonly IHttpClient _httpClient; + private readonly IJsonSerializer _jsonSerializer; private readonly ILogger _logger; - public ServerApiEndpoints(ILogger logger, IHttpClient httpClient) + public ServerApiEndpoints(ILogger logger, IJsonSerializer jsonSerializer, IHttpClient httpClient) { _logger = logger; + _jsonSerializer = jsonSerializer; _httpClient = httpClient; } private PushbulletOptions GetOptions(String userID) @@ -61,16 +64,19 @@ public async Task PostAsync(TestNotification request) string authInfo = options.Token; authInfo = Convert.ToBase64String(Encoding.UTF8.GetBytes(authInfo)); - _httpRequest.RequestHeaders["Authorization"] = "Basic " + authInfo; - - _httpRequest.Url = "https://api.pushbullet.com/v2/pushes"; - - _httpRequest.SetPostData(parameters); - - using (await _httpClient.Post(_httpRequest).ConfigureAwait(false)) - { - - } + var requestOptions = new HttpRequestOptions + { + Url = "https://api.pushbullet.com/v2/pushes", + RequestContent = _jsonSerializer.SerializeToString(parameters), + BufferContent = false, + RequestContentType = "application/json", + LogErrorResponseBody = true, + LogRequest = true, + DecompressionMethod = CompressionMethod.None, + EnableKeepAlive = false + }; + requestOptions.RequestHeaders["Authorization"] = "Basic " + authInfo; + await _httpClient.Post(requestOptions).ConfigureAwait(false); } } } From a756082b3643382ed146b5b0ebdd60adbf0f70fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20F=C3=A4th?= Date: Mon, 9 Sep 2019 11:03:49 +0200 Subject: [PATCH 03/14] Update build.yaml --- build.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.yaml b/build.yaml index 3a6f5f7..ecfdcaf 100644 --- a/build.yaml +++ b/build.yaml @@ -1,8 +1,8 @@ --- name: "jellyfin-plugin-pushbullet" guid: "de228f12-e43e-4bd9-9fc0-2830819c3b92" -version: "1" # Please increment with each pull request -jellyfin_version: "10.3.0" # The earliest binary-compatible version +version: "2" # Please increment with each pull request +jellyfin_version: "10.3.7" # The earliest binary-compatible version nicename: "Pushbullet" description: "Jellyfin Pushbullet notification plugin" overview: > From 3e88da7fe72c997af10ef9500509bf9dec85a1bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20F=C3=A4th?= Date: Mon, 9 Sep 2019 11:04:35 +0200 Subject: [PATCH 04/14] Update Pushbullet.csproj --- Pushbullet/Pushbullet.csproj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Pushbullet/Pushbullet.csproj b/Pushbullet/Pushbullet.csproj index b8a5b6d..49810d7 100644 --- a/Pushbullet/Pushbullet.csproj +++ b/Pushbullet/Pushbullet.csproj @@ -2,8 +2,8 @@ netstandard2.0; - 1.0.0 - 1.0.0 + 2.0.0 + 2.0.0 @@ -20,4 +20,4 @@ - \ No newline at end of file + From d10faaed917e240d4b354b35fe32bad0d62ec29a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20F=C3=A4th?= Date: Mon, 9 Sep 2019 13:10:32 +0200 Subject: [PATCH 05/14] Update Pushbullet/Api/ServerApiEntryPoints.cs Co-Authored-By: Claus Vium --- Pushbullet/Api/ServerApiEntryPoints.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Pushbullet/Api/ServerApiEntryPoints.cs b/Pushbullet/Api/ServerApiEntryPoints.cs index bbe453a..b5314c8 100644 --- a/Pushbullet/Api/ServerApiEntryPoints.cs +++ b/Pushbullet/Api/ServerApiEntryPoints.cs @@ -31,7 +31,7 @@ class ServerApiEndpoints : IService public ServerApiEndpoints(ILogger logger, IJsonSerializer jsonSerializer, IHttpClient httpClient) { _logger = logger; - _jsonSerializer = jsonSerializer; + _jsonSerializer = jsonSerializer; _httpClient = httpClient; } private PushbulletOptions GetOptions(String userID) From 2aab669b0d806d475e3d1cee72f83f01e9fec434 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20F=C3=A4th?= Date: Mon, 9 Sep 2019 13:13:35 +0200 Subject: [PATCH 06/14] Update ServerApiEntryPoints.cs --- Pushbullet/Api/ServerApiEntryPoints.cs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Pushbullet/Api/ServerApiEntryPoints.cs b/Pushbullet/Api/ServerApiEntryPoints.cs index b5314c8..5b56863 100644 --- a/Pushbullet/Api/ServerApiEntryPoints.cs +++ b/Pushbullet/Api/ServerApiEntryPoints.cs @@ -65,17 +65,17 @@ public async Task PostAsync(TestNotification request) authInfo = Convert.ToBase64String(Encoding.UTF8.GetBytes(authInfo)); var requestOptions = new HttpRequestOptions - { - Url = "https://api.pushbullet.com/v2/pushes", - RequestContent = _jsonSerializer.SerializeToString(parameters), - BufferContent = false, - RequestContentType = "application/json", - LogErrorResponseBody = true, - LogRequest = true, - DecompressionMethod = CompressionMethod.None, - EnableKeepAlive = false - }; - requestOptions.RequestHeaders["Authorization"] = "Basic " + authInfo; + { + Url = "https://api.pushbullet.com/v2/pushes", + RequestContent = _jsonSerializer.SerializeToString(parameters), + BufferContent = false, + RequestContentType = "application/json", + LogErrorResponseBody = true, + LogRequest = true, + DecompressionMethod = CompressionMethod.None, + EnableKeepAlive = false + }; + requestOptions.RequestHeaders["Authorization"] = "Basic " + authInfo; await _httpClient.Post(requestOptions).ConfigureAwait(false); } } From f767999c1b53687ec0003a399fb2cb832d639c92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20F=C3=A4th?= Date: Mon, 9 Sep 2019 13:14:52 +0200 Subject: [PATCH 07/14] Update Notifier.cs --- Pushbullet/Notifier.cs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Pushbullet/Notifier.cs b/Pushbullet/Notifier.cs index e49278c..20c45fd 100644 --- a/Pushbullet/Notifier.cs +++ b/Pushbullet/Notifier.cs @@ -62,17 +62,17 @@ public async Task SendNotification(UserNotification request, CancellationToken c authInfo = Convert.ToBase64String(Encoding.UTF8.GetBytes(authInfo)); var requestOptions = new HttpRequestOptions - { - Url = "https://api.pushbullet.com/v2/pushes", - RequestContent = _jsonSerializer.SerializeToString(parameters), - BufferContent = false, - RequestContentType = "application/json", - LogErrorResponseBody = true, - LogRequest = true, - DecompressionMethod = CompressionMethod.None, - EnableKeepAlive = false - }; - requestOptions.RequestHeaders["Authorization"] = "Basic " + authInfo; + { + Url = "https://api.pushbullet.com/v2/pushes", + RequestContent = _jsonSerializer.SerializeToString(parameters), + BufferContent = false, + RequestContentType = "application/json", + LogErrorResponseBody = true, + LogRequest = true, + DecompressionMethod = CompressionMethod.None, + EnableKeepAlive = false + }; + requestOptions.RequestHeaders["Authorization"] = "Basic " + authInfo; await _httpClient.Post(requestOptions).ConfigureAwait(false); } From a2f4637451fda0d9d97de7386a83c89af92d5002 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20F=C3=A4th?= Date: Mon, 9 Sep 2019 13:15:31 +0200 Subject: [PATCH 08/14] Update ServerApiEntryPoints.cs --- Pushbullet/Api/ServerApiEntryPoints.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Pushbullet/Api/ServerApiEntryPoints.cs b/Pushbullet/Api/ServerApiEntryPoints.cs index 5b56863..a3255bf 100644 --- a/Pushbullet/Api/ServerApiEntryPoints.cs +++ b/Pushbullet/Api/ServerApiEntryPoints.cs @@ -25,7 +25,7 @@ public class TestNotification : IReturnVoid class ServerApiEndpoints : IService { private readonly IHttpClient _httpClient; - private readonly IJsonSerializer _jsonSerializer; + private readonly IJsonSerializer _jsonSerializer; private readonly ILogger _logger; public ServerApiEndpoints(ILogger logger, IJsonSerializer jsonSerializer, IHttpClient httpClient) From a5ab0fcdbdd7ec0399a4b198fa68e7c389c12dfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20F=C3=A4th?= Date: Mon, 9 Sep 2019 13:43:18 +0200 Subject: [PATCH 09/14] Update PluginConfiguration.cs --- Pushbullet/Configuration/PluginConfiguration.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Pushbullet/Configuration/PluginConfiguration.cs b/Pushbullet/Configuration/PluginConfiguration.cs index e78a0a7..3c1104c 100644 --- a/Pushbullet/Configuration/PluginConfiguration.cs +++ b/Pushbullet/Configuration/PluginConfiguration.cs @@ -19,6 +19,7 @@ public class PushbulletOptions public Boolean Enabled { get; set; } public String Token { get; set; } public String DeviceId { get; set; } + public String Channel { get; set; } public string MediaBrowserUserId { get; set; } } From d9e1803251297175bc429e2ad481dbd66fb1c428 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20F=C3=A4th?= Date: Mon, 9 Sep 2019 13:47:10 +0200 Subject: [PATCH 10/14] Update config.html --- Pushbullet/Configuration/config.html | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Pushbullet/Configuration/config.html b/Pushbullet/Configuration/config.html index 448eb0d..6ebc451 100644 --- a/Pushbullet/Configuration/config.html +++ b/Pushbullet/Configuration/config.html @@ -17,6 +17,12 @@ Enabled +
+ +
+ Pushbullet channel +
+
@@ -56,6 +62,7 @@ })[0] || {}; $('#chkEnablePushbullet', page).checked(PushbulletConfig.Enabled || false).checkboxradio("refresh"); + $('#txtPushbulletChannel', page).val(PushbulletConfig.Channel || ''); $('#txtPushbulletAuthKey', page).val(PushbulletConfig.Token || ''); $('#txtPushbulletDeviceId', page).val(PushbulletConfig.DeviceId || ''); @@ -148,6 +155,7 @@ PushbulletConfig.MediaBrowserUserId = userId; PushbulletConfig.Enabled = $('#chkEnablePushbullet', form).checked(); + PushbulletConfig.Channel = $('#txtPushbulletChannel', form).val(); PushbulletConfig.Token = $('#txtPushbulletAuthKey', form).val(); PushbulletConfig.DeviceId = $('#txtPushbulletDeviceId', form).val(); @@ -162,4 +170,4 @@
- \ No newline at end of file + From 8afdc80b9021a3b46600bd9828473151f33e1128 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20F=C3=A4th?= Date: Mon, 9 Sep 2019 13:48:18 +0200 Subject: [PATCH 11/14] Update Notifier.cs --- Pushbullet/Notifier.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Pushbullet/Notifier.cs b/Pushbullet/Notifier.cs index 20c45fd..51a4938 100644 --- a/Pushbullet/Notifier.cs +++ b/Pushbullet/Notifier.cs @@ -51,6 +51,7 @@ public async Task SendNotification(UserNotification request, CancellationToken c var parameters = new Dictionary { // {"device_iden", options.DeviceId}, + {"channel_tag", options.Channel}, {"type", "note"}, {"title", request.Name}, {"body", request.Description} From dba896a5e3446764399494d2efa61f1a6edb5df2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20F=C3=A4th?= Date: Tue, 10 Sep 2019 12:59:12 +0200 Subject: [PATCH 12/14] Update PluginConfiguration.cs --- Pushbullet/Configuration/PluginConfiguration.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Pushbullet/Configuration/PluginConfiguration.cs b/Pushbullet/Configuration/PluginConfiguration.cs index 3c1104c..764c170 100644 --- a/Pushbullet/Configuration/PluginConfiguration.cs +++ b/Pushbullet/Configuration/PluginConfiguration.cs @@ -16,10 +16,10 @@ public PluginConfiguration() public class PushbulletOptions { - public Boolean Enabled { get; set; } - public String Token { get; set; } - public String DeviceId { get; set; } - public String Channel { get; set; } + public bool Enabled { get; set; } + public string Token { get; set; } + public string DeviceId { get; set; } + public string Channel { get; set; } public string MediaBrowserUserId { get; set; } } From 1fdd20b32a41cc2fb85a087d2fe9b4500f453c50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20F=C3=A4th?= Date: Mon, 16 Sep 2019 11:13:15 +0200 Subject: [PATCH 13/14] Update Notifier.cs --- Pushbullet/Notifier.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Pushbullet/Notifier.cs b/Pushbullet/Notifier.cs index 51a4938..c0a0138 100644 --- a/Pushbullet/Notifier.cs +++ b/Pushbullet/Notifier.cs @@ -69,7 +69,6 @@ public async Task SendNotification(UserNotification request, CancellationToken c BufferContent = false, RequestContentType = "application/json", LogErrorResponseBody = true, - LogRequest = true, DecompressionMethod = CompressionMethod.None, EnableKeepAlive = false }; From 90caa014973043f44d24d1cf3bc273a9effe3dec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20F=C3=A4th?= Date: Mon, 16 Sep 2019 11:13:30 +0200 Subject: [PATCH 14/14] Update ServerApiEntryPoints.cs --- Pushbullet/Api/ServerApiEntryPoints.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Pushbullet/Api/ServerApiEntryPoints.cs b/Pushbullet/Api/ServerApiEntryPoints.cs index a3255bf..5f1fb8e 100644 --- a/Pushbullet/Api/ServerApiEntryPoints.cs +++ b/Pushbullet/Api/ServerApiEntryPoints.cs @@ -71,7 +71,6 @@ public async Task PostAsync(TestNotification request) BufferContent = false, RequestContentType = "application/json", LogErrorResponseBody = true, - LogRequest = true, DecompressionMethod = CompressionMethod.None, EnableKeepAlive = false };