mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-17 17:14:18 +02:00
New: OnApplicationUpdate Notifications
(based on Radarr Commits 9e175e28efcfc6ac3e414649b955a10fb0e951e7 4f5f9ff77ee4de05ba04cc677eb7baf4df726af5 4ebcbc28aa3e3268ecc37c5fc2b5565da8f13305 ) Fixes #723 Co-authored-by: Qstick <qstick@gmail.com>
This commit is contained in:
@@ -61,12 +61,14 @@ class Notification extends Component {
|
||||
onRename,
|
||||
onDelete,
|
||||
onHealthIssue,
|
||||
onApplicationUpdate,
|
||||
supportsOnGrab,
|
||||
supportsOnDownload,
|
||||
supportsOnUpgrade,
|
||||
supportsOnRename,
|
||||
supportsOnDelete,
|
||||
supportsOnHealthIssue
|
||||
supportsOnHealthIssue,
|
||||
supportsOnApplicationUpdate
|
||||
} = this.props;
|
||||
|
||||
return (
|
||||
@@ -82,53 +84,62 @@ class Notification extends Component {
|
||||
{
|
||||
supportsOnGrab && onGrab &&
|
||||
<Label kind={kinds.SUCCESS}>
|
||||
On Grab
|
||||
{translate('OnGrab')}
|
||||
</Label>
|
||||
}
|
||||
|
||||
{
|
||||
supportsOnDelete && onDelete &&
|
||||
<Label kind={kinds.SUCCESS}>
|
||||
On Delete
|
||||
{translate('OnDelete')}
|
||||
</Label>
|
||||
}
|
||||
|
||||
{
|
||||
supportsOnDownload && onDownload &&
|
||||
<Label kind={kinds.SUCCESS}>
|
||||
On Import
|
||||
{translate('OnImport')}
|
||||
</Label>
|
||||
}
|
||||
|
||||
{
|
||||
supportsOnUpgrade && onDownload && onUpgrade &&
|
||||
<Label kind={kinds.SUCCESS}>
|
||||
On Upgrade
|
||||
{translate('OnUpgrade')}
|
||||
</Label>
|
||||
}
|
||||
|
||||
{
|
||||
supportsOnRename && onRename &&
|
||||
<Label kind={kinds.SUCCESS}>
|
||||
On Rename
|
||||
{translate('OnRename')}
|
||||
</Label>
|
||||
}
|
||||
|
||||
{
|
||||
supportsOnHealthIssue && onHealthIssue &&
|
||||
<Label kind={kinds.SUCCESS}>
|
||||
On Health Issue
|
||||
{translate('OnHealthIssue')}
|
||||
</Label>
|
||||
}
|
||||
|
||||
{
|
||||
!onGrab && !onDownload && !onRename && !onHealthIssue && !onDelete &&
|
||||
supportsOnApplicationUpdate && onApplicationUpdate ?
|
||||
<Label kind={kinds.SUCCESS}>
|
||||
{translate('OnApplicationUpdate')}
|
||||
</Label> :
|
||||
null
|
||||
}
|
||||
|
||||
{
|
||||
!onGrab && !onDownload && !onRename && !onHealthIssue && !onDelete && !onApplicationUpdate ?
|
||||
<Label
|
||||
kind={kinds.DISABLED}
|
||||
outline={true}
|
||||
>
|
||||
Disabled
|
||||
</Label>
|
||||
{translate('Disabled')}
|
||||
</Label> :
|
||||
null
|
||||
}
|
||||
|
||||
<EditNotificationModalConnector
|
||||
@@ -161,12 +172,14 @@ Notification.propTypes = {
|
||||
onRename: PropTypes.bool.isRequired,
|
||||
onDelete: PropTypes.bool.isRequired,
|
||||
onHealthIssue: PropTypes.bool.isRequired,
|
||||
onApplicationUpdate: PropTypes.bool.isRequired,
|
||||
supportsOnGrab: PropTypes.bool.isRequired,
|
||||
supportsOnDownload: PropTypes.bool.isRequired,
|
||||
supportsOnDelete: PropTypes.bool.isRequired,
|
||||
supportsOnUpgrade: PropTypes.bool.isRequired,
|
||||
supportsOnRename: PropTypes.bool.isRequired,
|
||||
supportsOnHealthIssue: PropTypes.bool.isRequired,
|
||||
supportsOnApplicationUpdate: PropTypes.bool.isRequired,
|
||||
onConfirmDeleteNotification: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
|
@@ -16,8 +16,10 @@ function NotificationEventItems(props) {
|
||||
|
||||
const {
|
||||
onHealthIssue,
|
||||
onApplicationUpdate,
|
||||
supportsOnHealthIssue,
|
||||
includeHealthWarnings
|
||||
includeHealthWarnings,
|
||||
supportsOnApplicationUpdate
|
||||
} = item;
|
||||
|
||||
return (
|
||||
@@ -53,6 +55,17 @@ function NotificationEventItems(props) {
|
||||
/>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div>
|
||||
<FormInputGroup
|
||||
type={inputTypes.CHECK}
|
||||
name="onApplicationUpdate"
|
||||
helpText={translate('OnApplicationUpdateHelpText')}
|
||||
isDisabled={!supportsOnApplicationUpdate.value}
|
||||
{...onApplicationUpdate}
|
||||
onChange={onInputChange}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</FormGroup>
|
||||
|
@@ -106,6 +106,7 @@ export default {
|
||||
selectedSchema.onDownload = selectedSchema.supportsOnDownload;
|
||||
selectedSchema.onUpgrade = selectedSchema.supportsOnUpgrade;
|
||||
selectedSchema.onRename = selectedSchema.supportsOnRename;
|
||||
selectedSchema.onApplicationUpdate = selectedSchema.supportsOnApplicationUpdate;
|
||||
|
||||
return selectedSchema;
|
||||
});
|
||||
|
@@ -0,0 +1,90 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FluentAssertions;
|
||||
using FluentValidation.Results;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Notifications;
|
||||
using NzbDrone.Core.ThingiProvider;
|
||||
using NzbDrone.Core.Validation;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.NotificationTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class NotificationBaseFixture : TestBase
|
||||
{
|
||||
private class TestSetting : IProviderConfig
|
||||
{
|
||||
public NzbDroneValidationResult Validate()
|
||||
{
|
||||
return new NzbDroneValidationResult();
|
||||
}
|
||||
}
|
||||
|
||||
private class TestNotificationWithApplicationUpdate : NotificationBase<TestSetting>
|
||||
{
|
||||
public override string Name => "TestNotification";
|
||||
public override string Link => "";
|
||||
|
||||
public override ValidationResult Test()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
||||
{
|
||||
TestLogger.Info("OnApplicationUpdate was called");
|
||||
}
|
||||
}
|
||||
|
||||
private class TestNotificationWithAllEvents : NotificationBase<TestSetting>
|
||||
{
|
||||
public override string Name => "TestNotification";
|
||||
public override string Link => "";
|
||||
|
||||
public override ValidationResult Test()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void OnHealthIssue(NzbDrone.Core.HealthCheck.HealthCheck artist)
|
||||
{
|
||||
TestLogger.Info("OnHealthIssue was called");
|
||||
}
|
||||
|
||||
public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
||||
{
|
||||
TestLogger.Info("OnApplicationUpdate was called");
|
||||
}
|
||||
}
|
||||
|
||||
private class TestNotificationWithNoEvents : NotificationBase<TestSetting>
|
||||
{
|
||||
public override string Name => "TestNotification";
|
||||
public override string Link => "";
|
||||
|
||||
public override ValidationResult Test()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_support_all_if_implemented()
|
||||
{
|
||||
var notification = new TestNotificationWithAllEvents();
|
||||
|
||||
notification.SupportsOnHealthIssue.Should().BeTrue();
|
||||
notification.SupportsOnApplicationUpdate.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_support_none_if_none_are_implemented()
|
||||
{
|
||||
var notification = new TestNotificationWithNoEvents();
|
||||
|
||||
notification.SupportsOnHealthIssue.Should().BeFalse();
|
||||
notification.SupportsOnApplicationUpdate.Should().BeFalse();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
using FluentMigrator;
|
||||
using NzbDrone.Core.Datastore.Migration.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migration
|
||||
{
|
||||
[Migration(014)]
|
||||
public class add_on_update_to_notifications : NzbDroneMigrationBase
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Alter.Table("Notifications").AddColumn("OnApplicationUpdate").AsBoolean().WithDefaultValue(0);
|
||||
}
|
||||
}
|
||||
}
|
@@ -63,7 +63,8 @@ namespace NzbDrone.Core.Datastore
|
||||
|
||||
Mapper.Entity<NotificationDefinition>("Notifications").RegisterModel()
|
||||
.Ignore(x => x.ImplementationName)
|
||||
.Ignore(i => i.SupportsOnHealthIssue);
|
||||
.Ignore(i => i.SupportsOnHealthIssue)
|
||||
.Ignore(i => i.SupportsOnApplicationUpdate);
|
||||
|
||||
Mapper.Entity<IndexerProxyDefinition>("IndexerProxies").RegisterModel()
|
||||
.Ignore(x => x.ImplementationName);
|
||||
|
@@ -262,6 +262,9 @@
|
||||
"NoUpdatesAreAvailable": "No updates are available",
|
||||
"OAuthPopupMessage": "Pop-ups are being blocked by your browser",
|
||||
"Ok": "Ok",
|
||||
"OnApplicationUpdate": "On Application Update",
|
||||
"OnApplicationUpdateHelpText": "On Application Update",
|
||||
"OnHealthIssue": "On Health Issue",
|
||||
"OnHealthIssueHelpText": "On Health Issue",
|
||||
"OpenBrowserOnStart": "Open browser on start",
|
||||
"OpenThisModal": "Open This Modal",
|
||||
|
16
src/NzbDrone.Core/Notifications/ApplicationUpdateMessage.cs
Normal file
16
src/NzbDrone.Core/Notifications/ApplicationUpdateMessage.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
|
||||
namespace NzbDrone.Core.Notifications
|
||||
{
|
||||
public class ApplicationUpdateMessage
|
||||
{
|
||||
public string Message { get; set; }
|
||||
public Version PreviousVersion { get; set; }
|
||||
public Version NewVersion { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return NewVersion.ToString();
|
||||
}
|
||||
}
|
||||
}
|
@@ -20,6 +20,11 @@ namespace NzbDrone.Core.Notifications.Boxcar
|
||||
_proxy.SendNotification(HEALTH_ISSUE_TITLE, message.Message, Settings);
|
||||
}
|
||||
|
||||
public override void OnApplicationUpdate(ApplicationUpdateMessage message)
|
||||
{
|
||||
_proxy.SendNotification(APPLICATION_UPDATE_TITLE, message.Message, Settings);
|
||||
}
|
||||
|
||||
public override ValidationResult Test()
|
||||
{
|
||||
var failures = new List<ValidationFailure>();
|
||||
|
@@ -44,6 +44,18 @@ namespace NzbDrone.Core.Notifications.CustomScript
|
||||
ExecuteScript(environmentVariables);
|
||||
}
|
||||
|
||||
public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
||||
{
|
||||
var environmentVariables = new StringDictionary();
|
||||
|
||||
environmentVariables.Add("Prowlarr_EventType", "ApplicationUpdate");
|
||||
environmentVariables.Add("Prowlarr_Update_Message", updateMessage.Message);
|
||||
environmentVariables.Add("Prowlarr_Update_NewVersion", updateMessage.NewVersion.ToString());
|
||||
environmentVariables.Add("Prowlarr_Update_PreviousVersion", updateMessage.PreviousVersion.ToString());
|
||||
|
||||
ExecuteScript(environmentVariables);
|
||||
}
|
||||
|
||||
public override ValidationResult Test()
|
||||
{
|
||||
var failures = new List<ValidationFailure>();
|
||||
|
@@ -42,6 +42,41 @@ namespace NzbDrone.Core.Notifications.Discord
|
||||
_proxy.SendPayload(payload, Settings);
|
||||
}
|
||||
|
||||
public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
||||
{
|
||||
var attachments = new List<Embed>
|
||||
{
|
||||
new Embed
|
||||
{
|
||||
Author = new DiscordAuthor
|
||||
{
|
||||
Name = Settings.Author.IsNullOrWhiteSpace() ? Environment.MachineName : Settings.Author,
|
||||
IconUrl = "https://raw.githubusercontent.com/Prowlarr/Prowlarr/develop/Logo/256.png"
|
||||
},
|
||||
Title = APPLICATION_UPDATE_TITLE,
|
||||
Timestamp = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss.fffZ"),
|
||||
Color = (int)DiscordColors.Standard,
|
||||
Fields = new List<DiscordField>()
|
||||
{
|
||||
new DiscordField()
|
||||
{
|
||||
Name = "Previous Version",
|
||||
Value = updateMessage.PreviousVersion.ToString()
|
||||
},
|
||||
new DiscordField()
|
||||
{
|
||||
Name = "New Version",
|
||||
Value = updateMessage.NewVersion.ToString()
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
var payload = CreatePayload(null, attachments);
|
||||
|
||||
_proxy.SendPayload(payload, Settings);
|
||||
}
|
||||
|
||||
public override ValidationResult Test()
|
||||
{
|
||||
var failures = new List<ValidationFailure>();
|
||||
|
@@ -28,6 +28,13 @@ namespace NzbDrone.Core.Notifications.Email
|
||||
SendEmail(Settings, HEALTH_ISSUE_TITLE_BRANDED, message.Message);
|
||||
}
|
||||
|
||||
public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
||||
{
|
||||
var body = $"{updateMessage.Message}";
|
||||
|
||||
SendEmail(Settings, APPLICATION_UPDATE_TITLE_BRANDED, body);
|
||||
}
|
||||
|
||||
public override ValidationResult Test()
|
||||
{
|
||||
var failures = new List<ValidationFailure>();
|
||||
|
@@ -24,6 +24,11 @@ namespace NzbDrone.Core.Notifications.Gotify
|
||||
_proxy.SendNotification(HEALTH_ISSUE_TITLE, healthCheck.Message, Settings);
|
||||
}
|
||||
|
||||
public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
||||
{
|
||||
_proxy.SendNotification(APPLICATION_UPDATE_TITLE, updateMessage.Message, Settings);
|
||||
}
|
||||
|
||||
public override ValidationResult Test()
|
||||
{
|
||||
var failures = new List<ValidationFailure>();
|
||||
|
@@ -7,7 +7,9 @@ namespace NzbDrone.Core.Notifications
|
||||
string Link { get; }
|
||||
|
||||
void OnHealthIssue(HealthCheck.HealthCheck healthCheck);
|
||||
void OnApplicationUpdate(ApplicationUpdateMessage updateMessage);
|
||||
void ProcessQueue();
|
||||
bool SupportsOnHealthIssue { get; }
|
||||
bool SupportsOnApplicationUpdate { get; }
|
||||
}
|
||||
}
|
||||
|
@@ -22,6 +22,11 @@ namespace NzbDrone.Core.Notifications.Join
|
||||
_proxy.SendNotification(HEALTH_ISSUE_TITLE_BRANDED, message.Message, Settings);
|
||||
}
|
||||
|
||||
public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
||||
{
|
||||
_proxy.SendNotification(APPLICATION_UPDATE_TITLE_BRANDED, updateMessage.Message, Settings);
|
||||
}
|
||||
|
||||
public override ValidationResult Test()
|
||||
{
|
||||
var failures = new List<ValidationFailure>();
|
||||
|
@@ -29,6 +29,18 @@ namespace NzbDrone.Core.Notifications.Notifiarr
|
||||
_proxy.SendNotification(variables, Settings);
|
||||
}
|
||||
|
||||
public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
||||
{
|
||||
var variables = new StringDictionary();
|
||||
|
||||
variables.Add("Prowlarr_EventType", "ApplicationUpdate");
|
||||
variables.Add("Prowlarr_Update_Message", updateMessage.Message);
|
||||
variables.Add("Prowlarr_Update_NewVersion", updateMessage.NewVersion.ToString());
|
||||
variables.Add("Prowlarr_Update_PreviousVersion", updateMessage.PreviousVersion.ToString());
|
||||
|
||||
_proxy.SendNotification(variables, Settings);
|
||||
}
|
||||
|
||||
public override ValidationResult Test()
|
||||
{
|
||||
var failures = new List<ValidationFailure>();
|
||||
|
@@ -9,8 +9,10 @@ namespace NzbDrone.Core.Notifications
|
||||
where TSettings : IProviderConfig, new()
|
||||
{
|
||||
protected const string HEALTH_ISSUE_TITLE = "Health Check Failure";
|
||||
protected const string APPLICATION_UPDATE_TITLE = "Application Updated";
|
||||
|
||||
protected const string HEALTH_ISSUE_TITLE_BRANDED = "Prowlarr - " + HEALTH_ISSUE_TITLE;
|
||||
protected const string APPLICATION_UPDATE_TITLE_BRANDED = "Prowlarr - " + APPLICATION_UPDATE_TITLE;
|
||||
|
||||
public abstract string Name { get; }
|
||||
|
||||
@@ -29,11 +31,16 @@ namespace NzbDrone.Core.Notifications
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void ProcessQueue()
|
||||
{
|
||||
}
|
||||
|
||||
public bool SupportsOnHealthIssue => HasConcreteImplementation("OnHealthIssue");
|
||||
public bool SupportsOnApplicationUpdate => HasConcreteImplementation("OnApplicationUpdate");
|
||||
|
||||
protected TSettings Settings => (TSettings)Definition.Settings;
|
||||
|
||||
|
@@ -5,9 +5,11 @@ namespace NzbDrone.Core.Notifications
|
||||
public class NotificationDefinition : ProviderDefinition
|
||||
{
|
||||
public bool OnHealthIssue { get; set; }
|
||||
public bool OnApplicationUpdate { get; set; }
|
||||
public bool SupportsOnHealthIssue { get; set; }
|
||||
public bool IncludeHealthWarnings { get; set; }
|
||||
public bool SupportsOnApplicationUpdate { get; set; }
|
||||
|
||||
public override bool Enable => OnHealthIssue;
|
||||
public override bool Enable => OnHealthIssue || OnApplicationUpdate;
|
||||
}
|
||||
}
|
||||
|
@@ -10,6 +10,7 @@ namespace NzbDrone.Core.Notifications
|
||||
public interface INotificationFactory : IProviderFactory<INotification, NotificationDefinition>
|
||||
{
|
||||
List<INotification> OnHealthIssueEnabled();
|
||||
List<INotification> OnApplicationUpdateEnabled();
|
||||
}
|
||||
|
||||
public class NotificationFactory : ProviderFactory<INotification, NotificationDefinition>, INotificationFactory
|
||||
@@ -24,11 +25,17 @@ namespace NzbDrone.Core.Notifications
|
||||
return GetAvailableProviders().Where(n => ((NotificationDefinition)n.Definition).OnHealthIssue).ToList();
|
||||
}
|
||||
|
||||
public List<INotification> OnApplicationUpdateEnabled()
|
||||
{
|
||||
return GetAvailableProviders().Where(n => ((NotificationDefinition)n.Definition).OnApplicationUpdate).ToList();
|
||||
}
|
||||
|
||||
public override void SetProviderCharacteristics(INotification provider, NotificationDefinition definition)
|
||||
{
|
||||
base.SetProviderCharacteristics(provider, definition);
|
||||
|
||||
definition.SupportsOnHealthIssue = provider.SupportsOnHealthIssue;
|
||||
definition.SupportsOnApplicationUpdate = provider.SupportsOnApplicationUpdate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -2,12 +2,14 @@ using System;
|
||||
using NLog;
|
||||
using NzbDrone.Core.HealthCheck;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
using NzbDrone.Core.Update.History.Events;
|
||||
|
||||
namespace NzbDrone.Core.Notifications
|
||||
{
|
||||
public class NotificationService
|
||||
: IHandle<HealthCheckFailedEvent>,
|
||||
IHandleAsync<HealthCheckCompleteEvent>
|
||||
IHandleAsync<HealthCheckCompleteEvent>,
|
||||
IHandle<UpdateInstalledEvent>
|
||||
{
|
||||
private readonly INotificationFactory _notificationFactory;
|
||||
private readonly Logger _logger;
|
||||
@@ -56,6 +58,26 @@ namespace NzbDrone.Core.Notifications
|
||||
ProcessQueue();
|
||||
}
|
||||
|
||||
public void Handle(UpdateInstalledEvent message)
|
||||
{
|
||||
var updateMessage = new ApplicationUpdateMessage();
|
||||
updateMessage.Message = $"Prowlarr updated from {message.PreviousVerison.ToString()} to {message.NewVersion.ToString()}";
|
||||
updateMessage.PreviousVersion = message.PreviousVerison;
|
||||
updateMessage.NewVersion = message.NewVersion;
|
||||
|
||||
foreach (var notification in _notificationFactory.OnApplicationUpdateEnabled())
|
||||
{
|
||||
try
|
||||
{
|
||||
notification.OnApplicationUpdate(updateMessage);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Warn(ex, "Unable to send OnApplicationUpdate notification to: " + notification.Definition.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ProcessQueue()
|
||||
{
|
||||
foreach (var notification in _notificationFactory.GetAvailableProviders())
|
||||
|
@@ -21,6 +21,11 @@ namespace NzbDrone.Core.Notifications.Prowl
|
||||
_prowlProxy.SendNotification(HEALTH_ISSUE_TITLE, healthCheck.Message, Settings);
|
||||
}
|
||||
|
||||
public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
||||
{
|
||||
_prowlProxy.SendNotification(APPLICATION_UPDATE_TITLE, updateMessage.Message, Settings);
|
||||
}
|
||||
|
||||
public override ValidationResult Test()
|
||||
{
|
||||
var failures = new List<ValidationFailure>();
|
||||
|
@@ -24,6 +24,11 @@ namespace NzbDrone.Core.Notifications.PushBullet
|
||||
_proxy.SendNotification(HEALTH_ISSUE_TITLE_BRANDED, healthCheck.Message, Settings);
|
||||
}
|
||||
|
||||
public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
||||
{
|
||||
_proxy.SendNotification(APPLICATION_UPDATE_TITLE_BRANDED, updateMessage.Message, Settings);
|
||||
}
|
||||
|
||||
public override ValidationResult Test()
|
||||
{
|
||||
var failures = new List<ValidationFailure>();
|
||||
|
@@ -21,6 +21,11 @@ namespace NzbDrone.Core.Notifications.Pushover
|
||||
_proxy.SendNotification(HEALTH_ISSUE_TITLE, healthCheck.Message, Settings);
|
||||
}
|
||||
|
||||
public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
||||
{
|
||||
_proxy.SendNotification(APPLICATION_UPDATE_TITLE, updateMessage.Message, Settings);
|
||||
}
|
||||
|
||||
public override ValidationResult Test()
|
||||
{
|
||||
var failures = new List<ValidationFailure>();
|
||||
|
@@ -24,6 +24,11 @@ namespace NzbDrone.Core.Notifications.SendGrid
|
||||
_proxy.SendNotification(HEALTH_ISSUE_TITLE, healthCheck.Message, Settings);
|
||||
}
|
||||
|
||||
public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
||||
{
|
||||
_proxy.SendNotification(APPLICATION_UPDATE_TITLE, updateMessage.Message, Settings);
|
||||
}
|
||||
|
||||
public override ValidationResult Test()
|
||||
{
|
||||
var failures = new List<ValidationFailure>();
|
||||
|
@@ -36,6 +36,23 @@ namespace NzbDrone.Core.Notifications.Slack
|
||||
_proxy.SendPayload(payload, Settings);
|
||||
}
|
||||
|
||||
public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
||||
{
|
||||
var attachments = new List<Attachment>
|
||||
{
|
||||
new Attachment
|
||||
{
|
||||
Title = Environment.MachineName,
|
||||
Text = updateMessage.Message,
|
||||
Color = "good"
|
||||
}
|
||||
};
|
||||
|
||||
var payload = CreatePayload("Application Updated", attachments);
|
||||
|
||||
_proxy.SendPayload(payload, Settings);
|
||||
}
|
||||
|
||||
public override ValidationResult Test()
|
||||
{
|
||||
var failures = new List<ValidationFailure>();
|
||||
|
@@ -21,6 +21,11 @@ namespace NzbDrone.Core.Notifications.Telegram
|
||||
_proxy.SendNotification(HEALTH_ISSUE_TITLE, healthCheck.Message, Settings);
|
||||
}
|
||||
|
||||
public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
||||
{
|
||||
_proxy.SendNotification(APPLICATION_UPDATE_TITLE, updateMessage.Message, Settings);
|
||||
}
|
||||
|
||||
public override ValidationResult Test()
|
||||
{
|
||||
var failures = new List<ValidationFailure>();
|
||||
|
@@ -23,6 +23,11 @@ namespace NzbDrone.Core.Notifications.Twitter
|
||||
_twitterService.SendNotification($"Health Issue: {healthCheck.Message}", Settings);
|
||||
}
|
||||
|
||||
public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
||||
{
|
||||
_twitterService.SendNotification($"Application Updated: {updateMessage.Message}", Settings);
|
||||
}
|
||||
|
||||
public override object RequestAction(string action, IDictionary<string, string> query)
|
||||
{
|
||||
if (action == "startOAuth")
|
||||
|
@@ -30,6 +30,19 @@ namespace NzbDrone.Core.Notifications.Webhook
|
||||
_proxy.SendWebhook(payload, Settings);
|
||||
}
|
||||
|
||||
public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
||||
{
|
||||
var payload = new WebhookApplicationUpdatePayload
|
||||
{
|
||||
EventType = WebhookEventType.ApplicationUpdate,
|
||||
Message = updateMessage.Message,
|
||||
PreviousVersion = updateMessage.PreviousVersion.ToString(),
|
||||
NewVersion = updateMessage.NewVersion.ToString()
|
||||
};
|
||||
|
||||
_proxy.SendWebhook(payload, Settings);
|
||||
}
|
||||
|
||||
public override string Name => "Webhook";
|
||||
|
||||
public override ValidationResult Test()
|
||||
|
@@ -0,0 +1,11 @@
|
||||
using NzbDrone.Core.HealthCheck;
|
||||
|
||||
namespace NzbDrone.Core.Notifications.Webhook
|
||||
{
|
||||
public class WebhookApplicationUpdatePayload : WebhookPayload
|
||||
{
|
||||
public string Message { get; set; }
|
||||
public string PreviousVersion { get; set; }
|
||||
public string NewVersion { get; set; }
|
||||
}
|
||||
}
|
@@ -12,6 +12,7 @@ namespace NzbDrone.Core.Notifications.Webhook
|
||||
Grab,
|
||||
Download,
|
||||
Rename,
|
||||
Health
|
||||
Health,
|
||||
ApplicationUpdate
|
||||
}
|
||||
}
|
||||
|
@@ -6,8 +6,10 @@ namespace Prowlarr.Api.V1.Notifications
|
||||
{
|
||||
public string Link { get; set; }
|
||||
public bool OnHealthIssue { get; set; }
|
||||
public bool OnApplicationUpdate { get; set; }
|
||||
public bool SupportsOnHealthIssue { get; set; }
|
||||
public bool IncludeHealthWarnings { get; set; }
|
||||
public bool SupportsOnApplicationUpdate { get; set; }
|
||||
public string TestCommand { get; set; }
|
||||
}
|
||||
|
||||
@@ -25,6 +27,8 @@ namespace Prowlarr.Api.V1.Notifications
|
||||
resource.OnHealthIssue = definition.OnHealthIssue;
|
||||
resource.SupportsOnHealthIssue = definition.SupportsOnHealthIssue;
|
||||
resource.IncludeHealthWarnings = definition.IncludeHealthWarnings;
|
||||
resource.OnApplicationUpdate = definition.OnApplicationUpdate;
|
||||
resource.SupportsOnApplicationUpdate = definition.SupportsOnApplicationUpdate;
|
||||
|
||||
return resource;
|
||||
}
|
||||
@@ -41,6 +45,8 @@ namespace Prowlarr.Api.V1.Notifications
|
||||
definition.OnHealthIssue = resource.OnHealthIssue;
|
||||
definition.SupportsOnHealthIssue = resource.SupportsOnHealthIssue;
|
||||
definition.IncludeHealthWarnings = resource.IncludeHealthWarnings;
|
||||
definition.OnApplicationUpdate = resource.OnApplicationUpdate;
|
||||
definition.SupportsOnApplicationUpdate = resource.SupportsOnApplicationUpdate;
|
||||
|
||||
return definition;
|
||||
}
|
||||
|
Reference in New Issue
Block a user