mirror of
https://github.com/Readarr/Readarr
synced 2025-12-28 03:09:38 +01:00
New: Health events for Webhooks
Signed-off-by: Robin Dadswell <robin@dadswell.email>
This commit is contained in:
parent
755fec154b
commit
5afe37e929
8 changed files with 67 additions and 14 deletions
|
|
@ -25,9 +25,9 @@ public override void OnGrab(GrabMessage message)
|
|||
|
||||
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 @@ public override void OnReleaseImport(BookDownloadMessage message)
|
|||
|
||||
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 @@ public override void OnReleaseImport(BookDownloadMessage message)
|
|||
|
||||
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 @@ public override void OnRename(Author author)
|
|||
|
||||
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 @@ private ValidationFailure SendWebhookTest()
|
|||
{
|
||||
var payload = new WebhookGrabPayload
|
||||
{
|
||||
EventType = "Test",
|
||||
Author = new WebhookAuthor()
|
||||
EventType = WebhookEventType.Test,
|
||||
Artist = new WebhookAuthor()
|
||||
{
|
||||
Id = 1,
|
||||
Name = "Test Name",
|
||||
|
|
|
|||
12
src/NzbDrone.Core/Notifications/Webhook/WebhookEventType.cs
Normal file
12
src/NzbDrone.Core/Notifications/Webhook/WebhookEventType.cs
Normal file
|
|
@ -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…
Reference in a new issue