From c6bb864be758b6f92baa0005bbc3650c8a5be513 Mon Sep 17 00:00:00 2001 From: David Pooley Date: Sun, 26 Aug 2018 20:57:39 +0100 Subject: [PATCH] Allow for the ability to set Pushover notification sound and priority from within Ombi. --- src/Ombi.Api.Pushover/IPushoverApi.cs | 2 +- src/Ombi.Api.Pushover/PushoverApi.cs | 4 +- .../Agents/PushoverNotification.cs | 2 +- .../Models/Notifications/PushoverSettings.cs | 2 + .../app/interfaces/INotificationSettings.ts | 2 + .../notifications/pushover.component.html | 42 +++++++++++++++++++ .../notifications/pushover.component.ts | 2 + 7 files changed, 52 insertions(+), 4 deletions(-) diff --git a/src/Ombi.Api.Pushover/IPushoverApi.cs b/src/Ombi.Api.Pushover/IPushoverApi.cs index 42e8e9060..554a15b60 100644 --- a/src/Ombi.Api.Pushover/IPushoverApi.cs +++ b/src/Ombi.Api.Pushover/IPushoverApi.cs @@ -5,6 +5,6 @@ namespace Ombi.Api.Pushover { public interface IPushoverApi { - Task PushAsync(string accessToken, string message, string userToken); + Task PushAsync(string accessToken, string message, string userToken, sbyte priority, string sound); } } \ No newline at end of file diff --git a/src/Ombi.Api.Pushover/PushoverApi.cs b/src/Ombi.Api.Pushover/PushoverApi.cs index fd6ca23ea..9f91bc7ca 100644 --- a/src/Ombi.Api.Pushover/PushoverApi.cs +++ b/src/Ombi.Api.Pushover/PushoverApi.cs @@ -16,13 +16,13 @@ namespace Ombi.Api.Pushover private readonly IApi _api; private const string PushoverEndpoint = "https://api.pushover.net/1"; - public async Task PushAsync(string accessToken, string message, string userToken) + public async Task PushAsync(string accessToken, string message, string userToken, sbyte priority, string sound) { if (message.Contains("'")) { message = message.Replace("'", "'"); } - var request = new Request($"messages.json?token={accessToken}&user={userToken}&message={WebUtility.HtmlEncode(message)}", PushoverEndpoint, HttpMethod.Post); + var request = new Request($"messages.json?token={accessToken}&user={userToken}&priority={priority}&sound={sound}&message={WebUtility.HtmlEncode(message)}", PushoverEndpoint, HttpMethod.Post); var result = await _api.Request(request); return result; diff --git a/src/Ombi.Notifications/Agents/PushoverNotification.cs b/src/Ombi.Notifications/Agents/PushoverNotification.cs index 5b82eb8a3..2719c3861 100644 --- a/src/Ombi.Notifications/Agents/PushoverNotification.cs +++ b/src/Ombi.Notifications/Agents/PushoverNotification.cs @@ -177,7 +177,7 @@ namespace Ombi.Notifications.Agents { try { - await Api.PushAsync(settings.AccessToken, model.Message, settings.UserToken); + await Api.PushAsync(settings.AccessToken, model.Message, settings.UserToken, settings.Priority, settings.Sound); } catch (Exception e) { diff --git a/src/Ombi.Settings/Settings/Models/Notifications/PushoverSettings.cs b/src/Ombi.Settings/Settings/Models/Notifications/PushoverSettings.cs index d845e8695..3e65d628d 100644 --- a/src/Ombi.Settings/Settings/Models/Notifications/PushoverSettings.cs +++ b/src/Ombi.Settings/Settings/Models/Notifications/PushoverSettings.cs @@ -8,5 +8,7 @@ namespace Ombi.Settings.Settings.Models.Notifications public bool Enabled { get; set; } public string AccessToken { get; set; } public string UserToken { get; set; } + public sbyte Priority { get; set; } + public string Sound { get; set; } } } \ No newline at end of file diff --git a/src/Ombi/ClientApp/app/interfaces/INotificationSettings.ts b/src/Ombi/ClientApp/app/interfaces/INotificationSettings.ts index 8c5fcd5bc..fc8b89f1e 100644 --- a/src/Ombi/ClientApp/app/interfaces/INotificationSettings.ts +++ b/src/Ombi/ClientApp/app/interfaces/INotificationSettings.ts @@ -88,6 +88,8 @@ export interface IPushoverNotificationSettings extends INotificationSettings { accessToken: string; notificationTemplates: INotificationTemplates[]; userToken: string; + priority: number; + sound: string; } export interface IMattermostNotifcationSettings extends INotificationSettings { diff --git a/src/Ombi/ClientApp/app/settings/notifications/pushover.component.html b/src/Ombi/ClientApp/app/settings/notifications/pushover.component.html index b56467c9f..499263dec 100644 --- a/src/Ombi/ClientApp/app/settings/notifications/pushover.component.html +++ b/src/Ombi/ClientApp/app/settings/notifications/pushover.component.html @@ -28,6 +28,48 @@ +
+ +
+ +
+
+ +
+ +
+ +
+
+
diff --git a/src/Ombi/ClientApp/app/settings/notifications/pushover.component.ts b/src/Ombi/ClientApp/app/settings/notifications/pushover.component.ts index 5d208568c..64f339192 100644 --- a/src/Ombi/ClientApp/app/settings/notifications/pushover.component.ts +++ b/src/Ombi/ClientApp/app/settings/notifications/pushover.component.ts @@ -27,6 +27,8 @@ export class PushoverComponent implements OnInit { enabled: [x.enabled], userToken: [x.userToken], accessToken: [x.accessToken, [Validators.required]], + priority: [x.priority], + sound: [x.sound], }); }); }