mirror of
https://github.com/Prowlarr/Prowlarr
synced 2025-12-06 08:34:28 +01:00
New: On Health Restored notification
(cherry picked from commit 5fdc8514da7c7ad98192f2ecb2415b3a7b5d0d05)
This commit is contained in:
parent
a753f721d1
commit
a86aa4c5d3
35 changed files with 279 additions and 10 deletions
|
|
@ -57,9 +57,11 @@ class Notification extends Component {
|
|||
name,
|
||||
onGrab,
|
||||
onHealthIssue,
|
||||
onHealthRestored,
|
||||
onApplicationUpdate,
|
||||
supportsOnGrab,
|
||||
supportsOnHealthIssue,
|
||||
supportsOnHealthRestored,
|
||||
supportsOnApplicationUpdate
|
||||
} = this.props;
|
||||
|
||||
|
|
@ -74,17 +76,27 @@ class Notification extends Component {
|
|||
</div>
|
||||
|
||||
{
|
||||
supportsOnGrab && onGrab &&
|
||||
supportsOnGrab && onGrab ?
|
||||
<Label kind={kinds.SUCCESS}>
|
||||
{translate('OnGrab')}
|
||||
</Label>
|
||||
</Label> :
|
||||
null
|
||||
}
|
||||
|
||||
{
|
||||
supportsOnHealthIssue && onHealthIssue &&
|
||||
supportsOnHealthIssue && onHealthIssue ?
|
||||
<Label kind={kinds.SUCCESS}>
|
||||
{translate('OnHealthIssue')}
|
||||
</Label>
|
||||
</Label> :
|
||||
null
|
||||
}
|
||||
|
||||
{
|
||||
supportsOnHealthRestored && onHealthRestored ?
|
||||
<Label kind={kinds.SUCCESS}>
|
||||
{translate('OnHealthRestored')}
|
||||
</Label> :
|
||||
null
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -96,7 +108,7 @@ class Notification extends Component {
|
|||
}
|
||||
|
||||
{
|
||||
!onGrab && !onHealthIssue && !onApplicationUpdate ?
|
||||
!onGrab && !onHealthIssue && !onHealthRestored && !onApplicationUpdate ?
|
||||
<Label
|
||||
kind={kinds.DISABLED}
|
||||
outline={true}
|
||||
|
|
@ -132,9 +144,11 @@ Notification.propTypes = {
|
|||
name: PropTypes.string.isRequired,
|
||||
onGrab: PropTypes.bool.isRequired,
|
||||
onHealthIssue: PropTypes.bool.isRequired,
|
||||
onHealthRestored: PropTypes.bool.isRequired,
|
||||
onApplicationUpdate: PropTypes.bool.isRequired,
|
||||
supportsOnGrab: PropTypes.bool.isRequired,
|
||||
supportsOnHealthIssue: PropTypes.bool.isRequired,
|
||||
supportsOnHealthRestored: PropTypes.bool.isRequired,
|
||||
supportsOnApplicationUpdate: PropTypes.bool.isRequired,
|
||||
onConfirmDeleteNotification: PropTypes.func.isRequired
|
||||
};
|
||||
|
|
|
|||
|
|
@ -17,10 +17,12 @@ function NotificationEventItems(props) {
|
|||
const {
|
||||
onGrab,
|
||||
onHealthIssue,
|
||||
onHealthRestored,
|
||||
onApplicationUpdate,
|
||||
supportsOnGrab,
|
||||
includeManualGrabs,
|
||||
supportsOnHealthIssue,
|
||||
supportsOnHealthRestored,
|
||||
includeHealthWarnings,
|
||||
supportsOnApplicationUpdate
|
||||
} = item;
|
||||
|
|
@ -70,8 +72,19 @@ function NotificationEventItems(props) {
|
|||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<FormInputGroup
|
||||
type={inputTypes.CHECK}
|
||||
name="onHealthRestored"
|
||||
helpText={translate('OnHealthRestoredHelpText')}
|
||||
isDisabled={!supportsOnHealthRestored.value}
|
||||
{...onHealthRestored}
|
||||
onChange={onInputChange}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{
|
||||
onHealthIssue.value &&
|
||||
(onHealthIssue.value || onHealthRestored.value) &&
|
||||
<div>
|
||||
<FormInputGroup
|
||||
type={inputTypes.CHECK}
|
||||
|
|
|
|||
|
|
@ -51,6 +51,11 @@ public override void OnHealthIssue(NzbDrone.Core.HealthCheck.HealthCheck artist)
|
|||
TestLogger.Info("OnHealthIssue was called");
|
||||
}
|
||||
|
||||
public override void OnHealthRestored(Core.HealthCheck.HealthCheck healthCheck)
|
||||
{
|
||||
TestLogger.Info("OnHealthRestored was called");
|
||||
}
|
||||
|
||||
public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
||||
{
|
||||
TestLogger.Info("OnApplicationUpdate was called");
|
||||
|
|
@ -79,6 +84,7 @@ public void should_support_all_if_implemented()
|
|||
var notification = new TestNotificationWithAllEvents();
|
||||
|
||||
notification.SupportsOnHealthIssue.Should().BeTrue();
|
||||
notification.SupportsOnHealthRestored.Should().BeTrue();
|
||||
notification.SupportsOnApplicationUpdate.Should().BeTrue();
|
||||
notification.SupportsOnGrab.Should().BeTrue();
|
||||
}
|
||||
|
|
@ -89,6 +95,7 @@ public void should_support_none_if_none_are_implemented()
|
|||
var notification = new TestNotificationWithNoEvents();
|
||||
|
||||
notification.SupportsOnHealthIssue.Should().BeFalse();
|
||||
notification.SupportsOnHealthRestored.Should().BeFalse();
|
||||
notification.SupportsOnApplicationUpdate.Should().BeFalse();
|
||||
notification.SupportsOnGrab.Should().BeFalse();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
using FluentMigrator;
|
||||
using NzbDrone.Core.Datastore.Migration.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migration
|
||||
{
|
||||
[Migration(032)]
|
||||
public class health_restored_notification : NzbDroneMigrationBase
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Alter.Table("Notifications").AddColumn("OnHealthRestored").AsBoolean().WithDefaultValue(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -69,6 +69,7 @@ public static void Map()
|
|||
.Ignore(x => x.ImplementationName)
|
||||
.Ignore(i => i.SupportsOnGrab)
|
||||
.Ignore(i => i.SupportsOnHealthIssue)
|
||||
.Ignore(i => i.SupportsOnHealthRestored)
|
||||
.Ignore(i => i.SupportsOnApplicationUpdate);
|
||||
|
||||
Mapper.Entity<IndexerProxyDefinition>("IndexerProxies").RegisterModel()
|
||||
|
|
|
|||
16
src/NzbDrone.Core/HealthCheck/HealthCheckRestoredEvent.cs
Normal file
16
src/NzbDrone.Core/HealthCheck/HealthCheckRestoredEvent.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
using NzbDrone.Common.Messaging;
|
||||
|
||||
namespace NzbDrone.Core.HealthCheck
|
||||
{
|
||||
public class HealthCheckRestoredEvent : IEvent
|
||||
{
|
||||
public HealthCheck PreviousCheck { get; private set; }
|
||||
public bool IsInStartupGracePeriod { get; private set; }
|
||||
|
||||
public HealthCheckRestoredEvent(HealthCheck previousCheck, bool isInStartupGracePeriod)
|
||||
{
|
||||
PreviousCheck = previousCheck;
|
||||
IsInStartupGracePeriod = isInStartupGracePeriod;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -91,6 +91,13 @@ private void PerformHealthCheck(IProvideHealthCheck[] healthChecks, bool perform
|
|||
{
|
||||
if (result.Type == HealthCheckResult.Ok)
|
||||
{
|
||||
var previous = _healthCheckResults.Find(result.Source.Name);
|
||||
|
||||
if (previous != null)
|
||||
{
|
||||
_eventAggregator.PublishEvent(new HealthCheckRestoredEvent(previous, !_hasRunHealthChecksAfterGracePeriod));
|
||||
}
|
||||
|
||||
_healthCheckResults.Remove(result.Source.Name);
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -294,6 +294,8 @@
|
|||
"OnGrabHelpText": "On Release Grab",
|
||||
"OnHealthIssue": "On Health Issue",
|
||||
"OnHealthIssueHelpText": "On Health Issue",
|
||||
"OnHealthRestored": "On Health Restored",
|
||||
"OnHealthRestoredHelpText": "On Health Restored",
|
||||
"OpenBrowserOnStart": "Open browser on start",
|
||||
"OpenThisModal": "Open This Modal",
|
||||
"Options": "Options",
|
||||
|
|
|
|||
|
|
@ -27,6 +27,11 @@ public override void OnHealthIssue(HealthCheck.HealthCheck healthCheck)
|
|||
_proxy.SendNotification(HEALTH_ISSUE_TITLE_BRANDED, healthCheck.Message, Settings);
|
||||
}
|
||||
|
||||
public override void OnHealthRestored(HealthCheck.HealthCheck previousCheck)
|
||||
{
|
||||
_proxy.SendNotification(HEALTH_RESTORED_TITLE, $"The following issue is now resolved: {previousCheck.Message}", Settings);
|
||||
}
|
||||
|
||||
public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
||||
{
|
||||
_proxy.SendNotification(APPLICATION_UPDATE_TITLE_BRANDED, updateMessage.Message, Settings);
|
||||
|
|
|
|||
|
|
@ -26,6 +26,11 @@ public override void OnHealthIssue(HealthCheck.HealthCheck message)
|
|||
_proxy.SendNotification(HEALTH_ISSUE_TITLE, message.Message, Settings);
|
||||
}
|
||||
|
||||
public override void OnHealthRestored(HealthCheck.HealthCheck previousCheck)
|
||||
{
|
||||
_proxy.SendNotification(HEALTH_RESTORED_TITLE, $"The following issue is now resolved: {previousCheck.Message}", Settings);
|
||||
}
|
||||
|
||||
public override void OnApplicationUpdate(ApplicationUpdateMessage message)
|
||||
{
|
||||
_proxy.SendNotification(APPLICATION_UPDATE_TITLE, message.Message, Settings);
|
||||
|
|
|
|||
|
|
@ -55,6 +55,21 @@ public override void OnHealthIssue(HealthCheck.HealthCheck healthCheck)
|
|||
ExecuteScript(environmentVariables);
|
||||
}
|
||||
|
||||
public override void OnHealthRestored(HealthCheck.HealthCheck previousCheck)
|
||||
{
|
||||
var environmentVariables = new StringDictionary();
|
||||
|
||||
environmentVariables.Add("Prowlarr_EventType", "HealthRestored");
|
||||
environmentVariables.Add("Prowlarr_InstanceName", _configFileProvider.InstanceName);
|
||||
environmentVariables.Add("Prowlarr_ApplicationUrl", _configService.ApplicationUrl);
|
||||
environmentVariables.Add("Prowlarr_Health_Restored_Level", Enum.GetName(typeof(HealthCheckResult), previousCheck.Type));
|
||||
environmentVariables.Add("Prowlarr_Health_Restored_Message", previousCheck.Message);
|
||||
environmentVariables.Add("Prowlarr_Health_Restored_Type", previousCheck.Source.Name);
|
||||
environmentVariables.Add("Prowlarr_Health_Restored_Wiki", previousCheck.WikiUrl.ToString() ?? string.Empty);
|
||||
|
||||
ExecuteScript(environmentVariables);
|
||||
}
|
||||
|
||||
public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
||||
{
|
||||
var environmentVariables = new StringDictionary();
|
||||
|
|
|
|||
|
|
@ -101,6 +101,29 @@ public override void OnHealthIssue(HealthCheck.HealthCheck healthCheck)
|
|||
_proxy.SendPayload(payload, Settings);
|
||||
}
|
||||
|
||||
public override void OnHealthRestored(HealthCheck.HealthCheck previousCheck)
|
||||
{
|
||||
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 = "Health Issue Resolved: " + previousCheck.Source.Name,
|
||||
Description = $"The following issue is now resolved: {previousCheck.Message}",
|
||||
Timestamp = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss.fffZ"),
|
||||
Color = (int)DiscordColors.Success
|
||||
}
|
||||
};
|
||||
|
||||
var payload = CreatePayload(null, attachments);
|
||||
|
||||
_proxy.SendPayload(payload, Settings);
|
||||
}
|
||||
|
||||
public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
||||
{
|
||||
var attachments = new List<Embed>
|
||||
|
|
|
|||
|
|
@ -36,6 +36,11 @@ public override void OnHealthIssue(HealthCheck.HealthCheck message)
|
|||
SendEmail(Settings, HEALTH_ISSUE_TITLE_BRANDED, message.Message);
|
||||
}
|
||||
|
||||
public override void OnHealthRestored(HealthCheck.HealthCheck previousMessage)
|
||||
{
|
||||
SendEmail(Settings, HEALTH_RESTORED_TITLE_BRANDED, $"The following issue is now resolved: {previousMessage.Message}");
|
||||
}
|
||||
|
||||
public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
||||
{
|
||||
var body = $"{updateMessage.Message}";
|
||||
|
|
|
|||
|
|
@ -29,6 +29,11 @@ public override void OnHealthIssue(HealthCheck.HealthCheck healthCheck)
|
|||
_proxy.SendNotification(HEALTH_ISSUE_TITLE, healthCheck.Message, Settings);
|
||||
}
|
||||
|
||||
public override void OnHealthRestored(HealthCheck.HealthCheck previousCheck)
|
||||
{
|
||||
_proxy.SendNotification(HEALTH_RESTORED_TITLE, $"The following issue is now resolved: {previousCheck.Message}", null);
|
||||
}
|
||||
|
||||
public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
||||
{
|
||||
_proxy.SendNotification(APPLICATION_UPDATE_TITLE, updateMessage.Message, Settings);
|
||||
|
|
|
|||
|
|
@ -8,10 +8,12 @@ public interface INotification : IProvider
|
|||
|
||||
void OnGrab(GrabMessage grabMessage);
|
||||
void OnHealthIssue(HealthCheck.HealthCheck healthCheck);
|
||||
void OnHealthRestored(HealthCheck.HealthCheck previousCheck);
|
||||
void OnApplicationUpdate(ApplicationUpdateMessage updateMessage);
|
||||
void ProcessQueue();
|
||||
bool SupportsOnGrab { get; }
|
||||
bool SupportsOnHealthIssue { get; }
|
||||
bool SupportsOnHealthRestored { get; }
|
||||
bool SupportsOnApplicationUpdate { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,11 @@ public override void OnHealthIssue(HealthCheck.HealthCheck message)
|
|||
_proxy.SendNotification(HEALTH_ISSUE_TITLE_BRANDED, message.Message, Settings);
|
||||
}
|
||||
|
||||
public override void OnHealthRestored(HealthCheck.HealthCheck previousMessage)
|
||||
{
|
||||
_proxy.SendNotification(HEALTH_RESTORED_TITLE_BRANDED, $"The following issue is now resolved: {previousMessage.Message}", Settings);
|
||||
}
|
||||
|
||||
public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
||||
{
|
||||
_proxy.SendNotification(APPLICATION_UPDATE_TITLE_BRANDED, updateMessage.Message, Settings);
|
||||
|
|
|
|||
|
|
@ -24,6 +24,11 @@ public override void OnHealthIssue(HealthCheck.HealthCheck healthCheckMessage)
|
|||
_proxy.SendNotification(HEALTH_ISSUE_TITLE, healthCheckMessage.Message, Settings);
|
||||
}
|
||||
|
||||
public override void OnHealthRestored(HealthCheck.HealthCheck previousCheckMessage)
|
||||
{
|
||||
_proxy.SendNotification(HEALTH_RESTORED_TITLE_BRANDED, $"The following issue is now resolved: {previousCheckMessage.Message}", Settings);
|
||||
}
|
||||
|
||||
public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
||||
{
|
||||
_proxy.SendNotification(APPLICATION_UPDATE_TITLE, updateMessage.Message, Settings);
|
||||
|
|
|
|||
|
|
@ -30,6 +30,11 @@ public override void OnHealthIssue(HealthCheck.HealthCheck healthCheck)
|
|||
_proxy.SendNotification(BuildHealthPayload(healthCheck), Settings);
|
||||
}
|
||||
|
||||
public override void OnHealthRestored(HealthCheck.HealthCheck previousCheck)
|
||||
{
|
||||
_proxy.SendNotification(BuildHealthRestoredPayload(previousCheck), Settings);
|
||||
}
|
||||
|
||||
public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
||||
{
|
||||
_proxy.SendNotification(BuildApplicationUploadPayload(updateMessage), Settings);
|
||||
|
|
|
|||
|
|
@ -10,10 +10,12 @@ public abstract class NotificationBase<TSettings> : INotification
|
|||
{
|
||||
protected const string RELEASE_GRABBED_TITLE = "Release Grabbed";
|
||||
protected const string HEALTH_ISSUE_TITLE = "Health Check Failure";
|
||||
protected const string HEALTH_RESTORED_TITLE = "Health Check Restored";
|
||||
protected const string APPLICATION_UPDATE_TITLE = "Application Updated";
|
||||
|
||||
protected const string RELEASE_GRABBED_TITLE_BRANDED = "Prowlarr - " + RELEASE_GRABBED_TITLE;
|
||||
protected const string HEALTH_ISSUE_TITLE_BRANDED = "Prowlarr - " + HEALTH_ISSUE_TITLE;
|
||||
protected const string HEALTH_RESTORED_TITLE_BRANDED = "Prowlarr - " + HEALTH_RESTORED_TITLE;
|
||||
protected const string APPLICATION_UPDATE_TITLE_BRANDED = "Prowlarr - " + APPLICATION_UPDATE_TITLE;
|
||||
|
||||
public abstract string Name { get; }
|
||||
|
|
@ -37,6 +39,10 @@ public virtual void OnHealthIssue(HealthCheck.HealthCheck healthCheck)
|
|||
{
|
||||
}
|
||||
|
||||
public virtual void OnHealthRestored(HealthCheck.HealthCheck previousCheck)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
||||
{
|
||||
}
|
||||
|
|
@ -47,6 +53,7 @@ public virtual void ProcessQueue()
|
|||
|
||||
public bool SupportsOnGrab => HasConcreteImplementation("OnGrab");
|
||||
public bool SupportsOnHealthIssue => HasConcreteImplementation("OnHealthIssue");
|
||||
public bool SupportsOnHealthRestored => HasConcreteImplementation("OnHealthRestored");
|
||||
public bool SupportsOnApplicationUpdate => HasConcreteImplementation("OnApplicationUpdate");
|
||||
|
||||
protected TSettings Settings => (TSettings)Definition.Settings;
|
||||
|
|
|
|||
|
|
@ -5,14 +5,16 @@ namespace NzbDrone.Core.Notifications
|
|||
public class NotificationDefinition : ProviderDefinition
|
||||
{
|
||||
public bool OnHealthIssue { get; set; }
|
||||
public bool OnHealthRestored { get; set; }
|
||||
public bool OnApplicationUpdate { get; set; }
|
||||
public bool OnGrab { get; set; }
|
||||
public bool SupportsOnGrab { get; set; }
|
||||
public bool IncludeManualGrabs { get; set; }
|
||||
public bool SupportsOnHealthIssue { get; set; }
|
||||
public bool SupportsOnHealthRestored { get; set; }
|
||||
public bool IncludeHealthWarnings { get; set; }
|
||||
public bool SupportsOnApplicationUpdate { get; set; }
|
||||
|
||||
public override bool Enable => OnHealthIssue || OnApplicationUpdate || OnGrab;
|
||||
public override bool Enable => OnHealthIssue || OnHealthRestored || OnApplicationUpdate || OnGrab;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ public interface INotificationFactory : IProviderFactory<INotification, Notifica
|
|||
{
|
||||
List<INotification> OnGrabEnabled();
|
||||
List<INotification> OnHealthIssueEnabled();
|
||||
List<INotification> OnHealthRestoredEnabled();
|
||||
List<INotification> OnApplicationUpdateEnabled();
|
||||
}
|
||||
|
||||
|
|
@ -31,6 +32,11 @@ public List<INotification> OnHealthIssueEnabled()
|
|||
return GetAvailableProviders().Where(n => ((NotificationDefinition)n.Definition).OnHealthIssue).ToList();
|
||||
}
|
||||
|
||||
public List<INotification> OnHealthRestoredEnabled()
|
||||
{
|
||||
return GetAvailableProviders().Where(n => ((NotificationDefinition)n.Definition).OnHealthRestored).ToList();
|
||||
}
|
||||
|
||||
public List<INotification> OnApplicationUpdateEnabled()
|
||||
{
|
||||
return GetAvailableProviders().Where(n => ((NotificationDefinition)n.Definition).OnApplicationUpdate).ToList();
|
||||
|
|
@ -42,6 +48,7 @@ public override void SetProviderCharacteristics(INotification provider, Notifica
|
|||
|
||||
definition.SupportsOnGrab = provider.SupportsOnGrab;
|
||||
definition.SupportsOnHealthIssue = provider.SupportsOnHealthIssue;
|
||||
definition.SupportsOnHealthRestored = provider.SupportsOnHealthRestored;
|
||||
definition.SupportsOnApplicationUpdate = provider.SupportsOnApplicationUpdate;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
using System;
|
||||
using System.Drawing.Drawing2D;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.HealthCheck;
|
||||
using NzbDrone.Core.Indexers.Events;
|
||||
using NzbDrone.Core.Indexers.PassThePopcorn;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Update.History.Events;
|
||||
|
|
@ -13,6 +11,7 @@ namespace NzbDrone.Core.Notifications
|
|||
{
|
||||
public class NotificationService
|
||||
: IHandle<HealthCheckFailedEvent>,
|
||||
IHandle<HealthCheckRestoredEvent>,
|
||||
IHandleAsync<HealthCheckCompleteEvent>,
|
||||
IHandle<UpdateInstalledEvent>,
|
||||
IHandle<IndexerDownloadEvent>
|
||||
|
|
@ -103,6 +102,29 @@ public void Handle(HealthCheckFailedEvent message)
|
|||
}
|
||||
}
|
||||
|
||||
public void Handle(HealthCheckRestoredEvent message)
|
||||
{
|
||||
if (message.IsInStartupGracePeriod)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var notification in _notificationFactory.OnHealthRestoredEnabled())
|
||||
{
|
||||
try
|
||||
{
|
||||
if (ShouldHandleHealthFailure(message.PreviousCheck, ((NotificationDefinition)notification.Definition).IncludeHealthWarnings))
|
||||
{
|
||||
notification.OnHealthRestored(message.PreviousCheck);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Warn(ex, "Unable to send OnHealthRestored notification to: " + notification.Definition.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void HandleAsync(HealthCheckCompleteEvent message)
|
||||
{
|
||||
ProcessQueue();
|
||||
|
|
|
|||
|
|
@ -27,6 +27,11 @@ public override void OnHealthIssue(HealthCheck.HealthCheck message)
|
|||
_proxy.SendNotification(HEALTH_ISSUE_TITLE_BRANDED, message.Message, Settings);
|
||||
}
|
||||
|
||||
public override void OnHealthRestored(HealthCheck.HealthCheck previousCheck)
|
||||
{
|
||||
_proxy.SendNotification(HEALTH_RESTORED_TITLE_BRANDED, $"The following issue is now resolved: {previousCheck.Message}", Settings);
|
||||
}
|
||||
|
||||
public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
||||
{
|
||||
_proxy.SendNotification(APPLICATION_UPDATE_TITLE_BRANDED, updateMessage.Message, Settings);
|
||||
|
|
|
|||
|
|
@ -26,6 +26,11 @@ public override void OnHealthIssue(HealthCheck.HealthCheck healthCheck)
|
|||
_prowlProxy.SendNotification(HEALTH_ISSUE_TITLE, healthCheck.Message, Settings);
|
||||
}
|
||||
|
||||
public override void OnHealthRestored(HealthCheck.HealthCheck previousMessage)
|
||||
{
|
||||
_prowlProxy.SendNotification(HEALTH_RESTORED_TITLE, $"The following issue is now resolved: {previousMessage.Message}", Settings);
|
||||
}
|
||||
|
||||
public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
||||
{
|
||||
_prowlProxy.SendNotification(APPLICATION_UPDATE_TITLE, updateMessage.Message, Settings);
|
||||
|
|
|
|||
|
|
@ -29,6 +29,11 @@ public override void OnHealthIssue(HealthCheck.HealthCheck healthCheck)
|
|||
_proxy.SendNotification(HEALTH_ISSUE_TITLE_BRANDED, healthCheck.Message, Settings);
|
||||
}
|
||||
|
||||
public override void OnHealthRestored(HealthCheck.HealthCheck previousCheck)
|
||||
{
|
||||
_proxy.SendNotification(HEALTH_RESTORED_TITLE_BRANDED, $"The following issue is now resolved: {previousCheck.Message}", Settings);
|
||||
}
|
||||
|
||||
public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
||||
{
|
||||
_proxy.SendNotification(APPLICATION_UPDATE_TITLE_BRANDED, updateMessage.Message, Settings);
|
||||
|
|
|
|||
|
|
@ -26,6 +26,11 @@ public override void OnHealthIssue(HealthCheck.HealthCheck healthCheck)
|
|||
_proxy.SendNotification(HEALTH_ISSUE_TITLE, healthCheck.Message, Settings);
|
||||
}
|
||||
|
||||
public override void OnHealthRestored(HealthCheck.HealthCheck previousCheck)
|
||||
{
|
||||
_proxy.SendNotification(HEALTH_RESTORED_TITLE, $"The following issue is now resolved: {previousCheck.Message}", Settings);
|
||||
}
|
||||
|
||||
public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
||||
{
|
||||
_proxy.SendNotification(APPLICATION_UPDATE_TITLE, updateMessage.Message, Settings);
|
||||
|
|
|
|||
|
|
@ -29,6 +29,11 @@ public override void OnHealthIssue(HealthCheck.HealthCheck healthCheck)
|
|||
_proxy.SendNotification(HEALTH_ISSUE_TITLE, healthCheck.Message, Settings);
|
||||
}
|
||||
|
||||
public override void OnHealthRestored(HealthCheck.HealthCheck previousCheck)
|
||||
{
|
||||
_proxy.SendNotification(HEALTH_RESTORED_TITLE, $"The following issue is now resolved: {previousCheck.Message}", Settings);
|
||||
}
|
||||
|
||||
public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
||||
{
|
||||
_proxy.SendNotification(APPLICATION_UPDATE_TITLE, updateMessage.Message, Settings);
|
||||
|
|
|
|||
|
|
@ -26,6 +26,11 @@ public override void OnHealthIssue(HealthCheck.HealthCheck healthCheck)
|
|||
_proxy.SendNotification(HEALTH_ISSUE_TITLE, healthCheck.Message, Settings);
|
||||
}
|
||||
|
||||
public override void OnHealthRestored(HealthCheck.HealthCheck previousCheck)
|
||||
{
|
||||
_proxy.SendNotification(HEALTH_RESTORED_TITLE, $"The following issue is now resolved: {previousCheck.Message}", Settings);
|
||||
}
|
||||
|
||||
public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
||||
{
|
||||
_proxy.SendNotification(APPLICATION_UPDATE_TITLE, updateMessage.Message, Settings);
|
||||
|
|
|
|||
|
|
@ -36,6 +36,23 @@ public override void OnHealthIssue(HealthCheck.HealthCheck healthCheck)
|
|||
_proxy.SendPayload(payload, Settings);
|
||||
}
|
||||
|
||||
public override void OnHealthRestored(HealthCheck.HealthCheck previousCheck)
|
||||
{
|
||||
var attachments = new List<Attachment>
|
||||
{
|
||||
new Attachment
|
||||
{
|
||||
Title = previousCheck.Source.Name,
|
||||
Text = $"The following issue is now resolved: {previousCheck.Message}",
|
||||
Color = "good"
|
||||
}
|
||||
};
|
||||
|
||||
var payload = CreatePayload("Health Issue Resolved", attachments);
|
||||
|
||||
_proxy.SendPayload(payload, Settings);
|
||||
}
|
||||
|
||||
public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
||||
{
|
||||
var attachments = new List<Attachment>
|
||||
|
|
|
|||
|
|
@ -26,6 +26,11 @@ public override void OnHealthIssue(HealthCheck.HealthCheck healthCheck)
|
|||
_proxy.SendNotification(HEALTH_ISSUE_TITLE, healthCheck.Message, Settings);
|
||||
}
|
||||
|
||||
public override void OnHealthRestored(HealthCheck.HealthCheck previousCheck)
|
||||
{
|
||||
_proxy.SendNotification(HEALTH_RESTORED_TITLE, $"The following issue is now resolved: {previousCheck.Message}", Settings);
|
||||
}
|
||||
|
||||
public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
||||
{
|
||||
_proxy.SendNotification(APPLICATION_UPDATE_TITLE, updateMessage.Message, Settings);
|
||||
|
|
|
|||
|
|
@ -29,6 +29,11 @@ public override void OnHealthIssue(HealthCheck.HealthCheck healthCheck)
|
|||
_twitterService.SendNotification($"Health Issue: {healthCheck.Message}", Settings);
|
||||
}
|
||||
|
||||
public override void OnHealthRestored(HealthCheck.HealthCheck previousCheck)
|
||||
{
|
||||
_twitterService.SendNotification($"Health Issue Resolved: {previousCheck.Message}", Settings);
|
||||
}
|
||||
|
||||
public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
||||
{
|
||||
_twitterService.SendNotification($"Application Updated: {updateMessage.Message}", Settings);
|
||||
|
|
|
|||
|
|
@ -28,6 +28,11 @@ public override void OnHealthIssue(HealthCheck.HealthCheck healthCheck)
|
|||
_proxy.SendWebhook(BuildHealthPayload(healthCheck), Settings);
|
||||
}
|
||||
|
||||
public override void OnHealthRestored(HealthCheck.HealthCheck previousCheck)
|
||||
{
|
||||
_proxy.SendWebhook(BuildHealthRestoredPayload(previousCheck), Settings);
|
||||
}
|
||||
|
||||
public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
||||
{
|
||||
_proxy.SendWebhook(BuildApplicationUploadPayload(updateMessage), Settings);
|
||||
|
|
|
|||
|
|
@ -46,6 +46,19 @@ protected WebhookHealthPayload BuildHealthPayload(HealthCheck.HealthCheck health
|
|||
};
|
||||
}
|
||||
|
||||
protected WebhookHealthPayload BuildHealthRestoredPayload(HealthCheck.HealthCheck healthCheck)
|
||||
{
|
||||
return new WebhookHealthPayload
|
||||
{
|
||||
EventType = WebhookEventType.HealthRestored,
|
||||
InstanceName = _configFileProvider.InstanceName,
|
||||
Level = healthCheck.Type,
|
||||
Message = healthCheck.Message,
|
||||
Type = healthCheck.Source.Name,
|
||||
WikiUrl = healthCheck.WikiUrl?.ToString()
|
||||
};
|
||||
}
|
||||
|
||||
protected WebhookApplicationUpdatePayload BuildApplicationUploadPayload(ApplicationUpdateMessage updateMessage)
|
||||
{
|
||||
return new WebhookApplicationUpdatePayload
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ public enum WebhookEventType
|
|||
Download,
|
||||
Rename,
|
||||
Health,
|
||||
ApplicationUpdate
|
||||
ApplicationUpdate,
|
||||
HealthRestored
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,10 +7,12 @@ public class NotificationResource : ProviderResource<NotificationResource>
|
|||
public string Link { get; set; }
|
||||
public bool OnGrab { get; set; }
|
||||
public bool OnHealthIssue { get; set; }
|
||||
public bool OnHealthRestored { get; set; }
|
||||
public bool OnApplicationUpdate { get; set; }
|
||||
public bool SupportsOnGrab { get; set; }
|
||||
public bool IncludeManualGrabs { get; set; }
|
||||
public bool SupportsOnHealthIssue { get; set; }
|
||||
public bool SupportsOnHealthRestored { get; set; }
|
||||
public bool IncludeHealthWarnings { get; set; }
|
||||
public bool SupportsOnApplicationUpdate { get; set; }
|
||||
public string TestCommand { get; set; }
|
||||
|
|
@ -31,7 +33,9 @@ public override NotificationResource ToResource(NotificationDefinition definitio
|
|||
resource.SupportsOnGrab = definition.SupportsOnGrab;
|
||||
resource.IncludeManualGrabs = definition.IncludeManualGrabs;
|
||||
resource.OnHealthIssue = definition.OnHealthIssue;
|
||||
resource.OnHealthRestored = definition.OnHealthRestored;
|
||||
resource.SupportsOnHealthIssue = definition.SupportsOnHealthIssue;
|
||||
resource.SupportsOnHealthRestored = definition.SupportsOnHealthRestored;
|
||||
resource.IncludeHealthWarnings = definition.IncludeHealthWarnings;
|
||||
resource.OnApplicationUpdate = definition.OnApplicationUpdate;
|
||||
resource.SupportsOnApplicationUpdate = definition.SupportsOnApplicationUpdate;
|
||||
|
|
@ -52,7 +56,9 @@ public override NotificationDefinition ToModel(NotificationResource resource)
|
|||
definition.SupportsOnGrab = resource.SupportsOnGrab;
|
||||
definition.IncludeManualGrabs = resource.IncludeManualGrabs;
|
||||
definition.OnHealthIssue = resource.OnHealthIssue;
|
||||
definition.OnHealthRestored = resource.OnHealthRestored;
|
||||
definition.SupportsOnHealthIssue = resource.SupportsOnHealthIssue;
|
||||
definition.SupportsOnHealthRestored = resource.SupportsOnHealthRestored;
|
||||
definition.IncludeHealthWarnings = resource.IncludeHealthWarnings;
|
||||
definition.OnApplicationUpdate = resource.OnApplicationUpdate;
|
||||
definition.SupportsOnApplicationUpdate = resource.SupportsOnApplicationUpdate;
|
||||
|
|
|
|||
Loading…
Reference in a new issue