mirror of
https://github.com/Readarr/Readarr
synced 2026-05-08 21:13:58 +02:00
New: Health events for Webhooks
Signed-off-by: Robin Dadswell <robin@dadswell.email>
This commit is contained in:
parent
8e78bf71a1
commit
e5f483eadc
8 changed files with 67 additions and 14 deletions
|
|
@ -25,9 +25,9 @@ public override void OnGrab(GrabMessage message)
|
||||||
|
|
||||||
var payload = new WebhookGrabPayload
|
var payload = new WebhookGrabPayload
|
||||||
{
|
{
|
||||||
EventType = "Grab",
|
EventType = WebhookEventType.Grab,
|
||||||
Author = new WebhookAuthor(message.Author),
|
Artist = new WebhookAuthor(message.Author),
|
||||||
Books = remoteBook.Books.ConvertAll(x => new WebhookBook(x)
|
Albums = remoteBook.Books.ConvertAll(x => new WebhookBook(x)
|
||||||
{
|
{
|
||||||
// TODO: Stop passing these parameters inside an album v3
|
// TODO: Stop passing these parameters inside an album v3
|
||||||
Quality = quality.Quality.Name,
|
Quality = quality.Quality.Name,
|
||||||
|
|
@ -48,7 +48,7 @@ public override void OnReleaseImport(BookDownloadMessage message)
|
||||||
|
|
||||||
var payload = new WebhookImportPayload
|
var payload = new WebhookImportPayload
|
||||||
{
|
{
|
||||||
EventType = "Download",
|
EventType = WebhookEventType.Download,
|
||||||
Artist = new WebhookAuthor(message.Author),
|
Artist = new WebhookAuthor(message.Author),
|
||||||
Book = new WebhookBook(message.Book),
|
Book = new WebhookBook(message.Book),
|
||||||
BookFiles = bookFiles.ConvertAll(x => new WebhookBookFile(x)),
|
BookFiles = bookFiles.ConvertAll(x => new WebhookBookFile(x)),
|
||||||
|
|
@ -62,10 +62,10 @@ public override void OnReleaseImport(BookDownloadMessage message)
|
||||||
|
|
||||||
public override void OnRename(Author author)
|
public override void OnRename(Author author)
|
||||||
{
|
{
|
||||||
var payload = new WebhookPayload
|
var payload = new WebhookRenamePayload
|
||||||
{
|
{
|
||||||
EventType = "Rename",
|
EventType = WebhookEventType.Rename,
|
||||||
Author = new WebhookAuthor(author)
|
Artist = new WebhookAuthor(author)
|
||||||
};
|
};
|
||||||
|
|
||||||
_proxy.SendWebhook(payload, Settings);
|
_proxy.SendWebhook(payload, Settings);
|
||||||
|
|
@ -73,15 +73,29 @@ public override void OnRename(Author author)
|
||||||
|
|
||||||
public override void OnBookRetag(BookRetagMessage message)
|
public override void OnBookRetag(BookRetagMessage message)
|
||||||
{
|
{
|
||||||
var payload = new WebhookPayload
|
var payload = new WebhookRetagPayload
|
||||||
{
|
{
|
||||||
EventType = "Retag",
|
EventType = WebhookEventType.Retag,
|
||||||
Author = new WebhookAuthor(message.Author)
|
Artist = new WebhookAuthor(message.Author)
|
||||||
};
|
};
|
||||||
|
|
||||||
_proxy.SendWebhook(payload, Settings);
|
_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 string Name => "Webhook";
|
||||||
|
|
||||||
public override ValidationResult Test()
|
public override ValidationResult Test()
|
||||||
|
|
@ -99,8 +113,8 @@ private ValidationFailure SendWebhookTest()
|
||||||
{
|
{
|
||||||
var payload = new WebhookGrabPayload
|
var payload = new WebhookGrabPayload
|
||||||
{
|
{
|
||||||
EventType = "Test",
|
EventType = WebhookEventType.Test,
|
||||||
Author = new WebhookAuthor()
|
Artist = new WebhookAuthor()
|
||||||
{
|
{
|
||||||
Id = 1,
|
Id = 1,
|
||||||
Name = "Test Name",
|
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 class WebhookGrabPayload : WebhookPayload
|
||||||
{
|
{
|
||||||
|
public WebhookAuthor Author { get; set; }
|
||||||
public List<WebhookBook> Books { get; set; }
|
public List<WebhookBook> Books { get; set; }
|
||||||
public WebhookRelease Release { get; set; }
|
public WebhookRelease Release { get; set; }
|
||||||
public string DownloadClient { 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 class WebhookImportPayload : WebhookPayload
|
||||||
{
|
{
|
||||||
|
public WebhookAuthor Author { get; set; }
|
||||||
public WebhookBook Book { get; set; }
|
public WebhookBook Book { get; set; }
|
||||||
public List<WebhookBookFile> BookFiles { get; set; }
|
public List<WebhookBookFile> BookFiles { get; set; }
|
||||||
public bool IsUpgrade { get; set; }
|
public bool IsUpgrade { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ namespace NzbDrone.Core.Notifications.Webhook
|
||||||
{
|
{
|
||||||
public class WebhookPayload
|
public class WebhookPayload
|
||||||
{
|
{
|
||||||
public string EventType { get; set; }
|
public WebhookEventType EventType { get; set; }
|
||||||
public WebhookAuthor Author { 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