From 949922b9a1873dc228c0693eea63af6f8c854f0d Mon Sep 17 00:00:00 2001 From: Stevie Robinson Date: Wed, 12 Nov 2025 20:14:09 +0100 Subject: [PATCH] New: add TTL setting for pushover notifications (cherry picked from commit 317cdf15582746bd4e713d6b99e17a21dcb8abeb) --- src/NzbDrone.Core/Localization/Core/en.json | 4 +++- src/NzbDrone.Core/Notifications/Pushover/PushoverProxy.cs | 5 +++++ .../Notifications/Pushover/PushoverSettings.cs | 6 +++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/NzbDrone.Core/Localization/Core/en.json b/src/NzbDrone.Core/Localization/Core/en.json index 62db7f5f7b..23a3b71ab8 100644 --- a/src/NzbDrone.Core/Localization/Core/en.json +++ b/src/NzbDrone.Core/Localization/Core/en.json @@ -1340,11 +1340,13 @@ "NotificationsPushoverSettingsDevices": "Devices", "NotificationsPushoverSettingsDevicesHelpText": "List of device names (leave blank to send to all devices)", "NotificationsPushoverSettingsExpire": "Expire", - "NotificationsPushoverSettingsExpireHelpText": "Maximum time to retry Emergency alerts, maximum 86400 seconds\"", + "NotificationsPushoverSettingsExpireHelpText": "Maximum time to retry Emergency alerts, maximum 86400 seconds", "NotificationsPushoverSettingsRetry": "Retry", "NotificationsPushoverSettingsRetryHelpText": "Interval to retry Emergency alerts, minimum 30 seconds", "NotificationsPushoverSettingsSound": "Sound", "NotificationsPushoverSettingsSoundHelpText": "Notification sound, leave blank to use the default", + "NotificationsPushoverSettingsTtl": "Time To Live", + "NotificationsPushoverSettingsTtlHelpText": "Time in seconds before the message expires. Set to 0 for unlimited duration", "NotificationsPushoverSettingsUserKey": "User Key", "NotificationsSendGridSettingsApiKeyHelpText": "The API Key generated by SendGrid", "NotificationsSettingsUpdateLibrary": "Update Library", diff --git a/src/NzbDrone.Core/Notifications/Pushover/PushoverProxy.cs b/src/NzbDrone.Core/Notifications/Pushover/PushoverProxy.cs index df5658ce3a..2207c561e7 100644 --- a/src/NzbDrone.Core/Notifications/Pushover/PushoverProxy.cs +++ b/src/NzbDrone.Core/Notifications/Pushover/PushoverProxy.cs @@ -45,6 +45,11 @@ public void SendNotification(string title, string message, PushoverSettings sett requestBuilder.AddFormParameter("expire", settings.Expire); } + if (settings.Ttl > 0) + { + requestBuilder.AddFormParameter("ttl", settings.Ttl); + } + if (!settings.Sound.IsNullOrWhiteSpace()) { requestBuilder.AddFormParameter("sound", settings.Sound); diff --git a/src/NzbDrone.Core/Notifications/Pushover/PushoverSettings.cs b/src/NzbDrone.Core/Notifications/Pushover/PushoverSettings.cs index c9279e0314..6c85e7dd25 100644 --- a/src/NzbDrone.Core/Notifications/Pushover/PushoverSettings.cs +++ b/src/NzbDrone.Core/Notifications/Pushover/PushoverSettings.cs @@ -13,6 +13,7 @@ public PushoverSettingsValidator() RuleFor(c => c.UserKey).NotEmpty(); RuleFor(c => c.Retry).GreaterThanOrEqualTo(30).LessThanOrEqualTo(86400).When(c => (PushoverPriority)c.Priority == PushoverPriority.Emergency); RuleFor(c => c.Retry).GreaterThanOrEqualTo(0).LessThanOrEqualTo(86400).When(c => (PushoverPriority)c.Priority == PushoverPriority.Emergency); + RuleFor(c => c.Ttl).GreaterThanOrEqualTo(0); } } @@ -44,7 +45,10 @@ public PushoverSettings() [FieldDefinition(5, Label = "NotificationsPushoverSettingsExpire", Type = FieldType.Textbox, HelpText = "NotificationsPushoverSettingsExpireHelpText")] public int Expire { get; set; } - [FieldDefinition(6, Label = "NotificationsPushoverSettingsSound", Type = FieldType.Textbox, HelpText = "NotificationsPushoverSettingsSoundHelpText", HelpLink = "https://pushover.net/api#sounds")] + [FieldDefinition(6, Label = "NotificationsPushoverSettingsTtl", Type = FieldType.Textbox, HelpText = "NotificationsPushoverSettingsTtlHelpText", Advanced = true)] + public int Ttl { get; set; } + + [FieldDefinition(7, Label = "NotificationsPushoverSettingsSound", Type = FieldType.Textbox, HelpText = "NotificationsPushoverSettingsSoundHelpText", HelpLink = "https://pushover.net/api#sounds")] public string Sound { get; set; } public bool IsValid => !string.IsNullOrWhiteSpace(UserKey) && Priority >= -1 && Priority <= 2;