New: Health events for Webhooks

pull/3992/head
Mark McDowall 4 years ago
parent 43cb44dd38
commit ee32829cdb

@ -26,7 +26,7 @@ namespace NzbDrone.Core.Notifications.Webhook
var payload = new WebhookGrabPayload
{
EventType = "Grab",
EventType = WebhookEventType.Grab,
Series = new WebhookSeries(message.Series),
Episodes = remoteEpisode.Episodes.ConvertAll(x => new WebhookEpisode(x)),
Release = new WebhookRelease(quality, remoteEpisode),
@ -43,7 +43,7 @@ namespace NzbDrone.Core.Notifications.Webhook
var payload = new WebhookImportPayload
{
EventType = "Download",
EventType = WebhookEventType.Download,
Series = new WebhookSeries(message.Series),
Episodes = episodeFile.Episodes.Value.ConvertAll(x => new WebhookEpisode(x)),
EpisodeFile = new WebhookEpisodeFile(episodeFile),
@ -67,15 +67,29 @@ namespace NzbDrone.Core.Notifications.Webhook
public override void OnRename(Series series)
{
var payload = new WebhookPayload
var payload = new WebhookRenamePayload
{
EventType = "Rename",
EventType = WebhookEventType.Rename,
Series = new WebhookSeries(series)
};
_proxy.SendWebhook(payload, Settings);
}
public override void OnHealthIssue(HealthCheck.HealthCheck healthCheck)
{
var payload = new WebhookHealthPayload
{
EventType = WebhookEventType.Health,
Level = healthCheck.Type,
Message = healthCheck.Message,
Type = healthCheck.Source.Name,
WikiUrl = healthCheck.WikiUrl?.ToString()
};
_proxy.SendWebhook(payload, Settings);
}
public override string Name => "Webhook";
public override ValidationResult Test()
@ -93,7 +107,7 @@ namespace NzbDrone.Core.Notifications.Webhook
{
var payload = new WebhookGrabPayload
{
EventType = "Test",
EventType = WebhookEventType.Test,
Series = new WebhookSeries()
{
Id = 1,

@ -0,0 +1,11 @@
namespace NzbDrone.Core.Notifications.Webhook
{
public enum WebhookEventType
{
Test,
Grab,
Download,
Rename,
Health
}
}

@ -4,6 +4,7 @@ namespace NzbDrone.Core.Notifications.Webhook
{
public class WebhookGrabPayload : WebhookPayload
{
public WebhookSeries Series { get; set; }
public List<WebhookEpisode> Episodes { get; set; }
public WebhookRelease Release { get; set; }
public string DownloadClient { get; set; }

@ -0,0 +1,12 @@
using NzbDrone.Core.HealthCheck;
namespace NzbDrone.Core.Notifications.Webhook
{
public class WebhookHealthPayload : WebhookPayload
{
public HealthCheckResult Level { get; set; }
public string Message { get; set; }
public string Type { get; set; }
public string WikiUrl { get; set; }
}
}

@ -4,6 +4,7 @@ namespace NzbDrone.Core.Notifications.Webhook
{
public class WebhookImportPayload : WebhookPayload
{
public WebhookSeries Series { get; set; }
public List<WebhookEpisode> Episodes { get; set; }
public WebhookEpisodeFile EpisodeFile { get; set; }
public bool IsUpgrade { get; set; }

@ -2,7 +2,6 @@
{
public class WebhookPayload
{
public string EventType { get; set; }
public WebhookSeries Series { get; set; }
public WebhookEventType EventType { get; set; }
}
}

@ -0,0 +1,7 @@
namespace NzbDrone.Core.Notifications.Webhook
{
public class WebhookRenamePayload : WebhookPayload
{
public WebhookSeries Series { get; set; }
}
}
Loading…
Cancel
Save