New: Health events for Webhooks

Signed-off-by: Robin Dadswell <robin@dadswell.email>
pull/770/head
Mark McDowall 4 years ago committed by Qstick
parent 755fec154b
commit 5afe37e929

@ -25,9 +25,9 @@ namespace NzbDrone.Core.Notifications.Webhook
var payload = new WebhookGrabPayload
{
EventType = "Grab",
Author = new WebhookAuthor(message.Author),
Books = remoteBook.Books.ConvertAll(x => new WebhookBook(x)
EventType = WebhookEventType.Grab,
Artist = new WebhookAuthor(message.Author),
Albums = remoteBook.Books.ConvertAll(x => new WebhookBook(x)
{
// TODO: Stop passing these parameters inside an album v3
Quality = quality.Quality.Name,
@ -48,7 +48,7 @@ namespace NzbDrone.Core.Notifications.Webhook
var payload = new WebhookImportPayload
{
EventType = "Download",
EventType = WebhookEventType.Download,
Artist = new WebhookAuthor(message.Author),
Book = new WebhookBook(message.Book),
BookFiles = bookFiles.ConvertAll(x => new WebhookBookFile(x)),
@ -62,10 +62,10 @@ namespace NzbDrone.Core.Notifications.Webhook
public override void OnRename(Author author)
{
var payload = new WebhookPayload
var payload = new WebhookRenamePayload
{
EventType = "Rename",
Author = new WebhookAuthor(author)
EventType = WebhookEventType.Rename,
Artist = new WebhookAuthor(author)
};
_proxy.SendWebhook(payload, Settings);
@ -73,15 +73,29 @@ namespace NzbDrone.Core.Notifications.Webhook
public override void OnBookRetag(BookRetagMessage message)
{
var payload = new WebhookPayload
var payload = new WebhookRetagPayload
{
EventType = "Retag",
Author = new WebhookAuthor(message.Author)
EventType = WebhookEventType.Retag,
Artist = new WebhookAuthor(message.Author)
};
_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()
@ -99,8 +113,8 @@ namespace NzbDrone.Core.Notifications.Webhook
{
var payload = new WebhookGrabPayload
{
EventType = "Test",
Author = new WebhookAuthor()
EventType = WebhookEventType.Test,
Artist = new WebhookAuthor()
{
Id = 1,
Name = "Test Name",

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

@ -4,6 +4,7 @@ namespace NzbDrone.Core.Notifications.Webhook
{
public class WebhookGrabPayload : WebhookPayload
{
public WebhookAuthor Author { get; set; }
public List<WebhookBook> Books { 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 WebhookAuthor Author { get; set; }
public WebhookBook Book { get; set; }
public List<WebhookBookFile> BookFiles { get; set; }
public bool IsUpgrade { get; set; }

@ -2,7 +2,6 @@ namespace NzbDrone.Core.Notifications.Webhook
{
public class WebhookPayload
{
public string EventType { get; set; }
public WebhookAuthor Author { get; set; }
public WebhookEventType EventType { get; set; }
}
}

@ -0,0 +1,7 @@
namespace NzbDrone.Core.Notifications.Webhook
{
public class WebhookRenamePayload : WebhookPayload
{
public WebhookArtist Artist { get; set; }
}
}

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