diff --git a/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs b/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs index 1812b9f72..db9e862b9 100755 --- a/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs @@ -26,7 +26,7 @@ public override void OnGrab(GrabMessage message) var payload = new WebhookGrabPayload { - EventType = "Grab", + EventType = WebhookEventType.Grab, Movie = new WebhookMovie(message.Movie), RemoteMovie = new WebhookRemoteMovie(remoteMovie), Release = new WebhookRelease(quality, remoteMovie), @@ -43,7 +43,7 @@ public override void OnDownload(DownloadMessage message) var payload = new WebhookImportPayload { - EventType = "Download", + EventType = WebhookEventType.Download, Movie = new WebhookMovie(message.Movie), RemoteMovie = new WebhookRemoteMovie(message.Movie), MovieFile = new WebhookMovieFile(movieFile), @@ -66,15 +66,29 @@ public override void OnDownload(DownloadMessage message) public override void OnMovieRename(Movie movie) { - var payload = new WebhookPayload + var payload = new WebhookRenamePayload { - EventType = "Rename", + EventType = WebhookEventType.Rename, Movie = new WebhookMovie(movie) }; _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() @@ -92,7 +106,7 @@ private ValidationFailure SendWebhookTest() { var payload = new WebhookGrabPayload { - EventType = "Test", + EventType = WebhookEventType.Test, Movie = new WebhookMovie { Id = 1, diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookEventType.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookEventType.cs new file mode 100644 index 000000000..8c7036d92 --- /dev/null +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookEventType.cs @@ -0,0 +1,17 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Serialization; + +namespace NzbDrone.Core.Notifications.Webhook +{ + // TODO: In v4 this will likely be changed to the default camel case. + [JsonConverter(typeof(StringEnumConverter), converterParameters: typeof(DefaultNamingStrategy))] + public enum WebhookEventType + { + Test, + Grab, + Download, + Rename, + Health + } +} diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookGrabPayload.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookGrabPayload.cs index ab5a0424e..88abd5571 100755 --- a/src/NzbDrone.Core/Notifications/Webhook/WebhookGrabPayload.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookGrabPayload.cs @@ -2,6 +2,7 @@ namespace NzbDrone.Core.Notifications.Webhook { public class WebhookGrabPayload : WebhookPayload { + public WebhookMovie Movie { get; set; } public WebhookRemoteMovie RemoteMovie { get; set; } public WebhookRelease Release { get; set; } public string DownloadClient { get; set; } diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookHealthPayload.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookHealthPayload.cs new file mode 100644 index 000000000..0fb4f9a03 --- /dev/null +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookHealthPayload.cs @@ -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; } + } +} diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookImportPayload.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookImportPayload.cs index e44a4564b..f1795837b 100755 --- a/src/NzbDrone.Core/Notifications/Webhook/WebhookImportPayload.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookImportPayload.cs @@ -4,6 +4,7 @@ namespace NzbDrone.Core.Notifications.Webhook { public class WebhookImportPayload : WebhookPayload { + public WebhookMovie Movie { get; set; } public WebhookRemoteMovie RemoteMovie { get; set; } public WebhookMovieFile MovieFile { get; set; } public bool IsUpgrade { get; set; } diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookPayload.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookPayload.cs index 91a936272..4b63a748e 100755 --- a/src/NzbDrone.Core/Notifications/Webhook/WebhookPayload.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookPayload.cs @@ -2,7 +2,6 @@ namespace NzbDrone.Core.Notifications.Webhook { public class WebhookPayload { - public string EventType { get; set; } - public WebhookMovie Movie { get; set; } + public WebhookEventType EventType { get; set; } } } diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookRenamePayload.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookRenamePayload.cs new file mode 100644 index 000000000..7f3d9fa8b --- /dev/null +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookRenamePayload.cs @@ -0,0 +1,7 @@ +namespace NzbDrone.Core.Notifications.Webhook +{ + public class WebhookRenamePayload : WebhookPayload + { + public WebhookMovie Movie { get; set; } + } +}