mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-30 03:38:26 -07:00
New: Health events for Webhooks
This commit is contained in:
parent
5a15565d2b
commit
acda741b2b
8 changed files with 62 additions and 9 deletions
|
@ -25,7 +25,7 @@ namespace NzbDrone.Core.Notifications.Webhook
|
||||||
|
|
||||||
var payload = new WebhookGrabPayload
|
var payload = new WebhookGrabPayload
|
||||||
{
|
{
|
||||||
EventType = "Grab",
|
EventType = WebhookEventType.Grab,
|
||||||
Artist = new WebhookArtist(message.Artist),
|
Artist = new WebhookArtist(message.Artist),
|
||||||
Albums = remoteAlbum.Albums.ConvertAll(x => new WebhookAlbum(x)
|
Albums = remoteAlbum.Albums.ConvertAll(x => new WebhookAlbum(x)
|
||||||
{
|
{
|
||||||
|
@ -48,7 +48,7 @@ namespace NzbDrone.Core.Notifications.Webhook
|
||||||
|
|
||||||
var payload = new WebhookImportPayload
|
var payload = new WebhookImportPayload
|
||||||
{
|
{
|
||||||
EventType = "Download",
|
EventType = WebhookEventType.Download,
|
||||||
Artist = new WebhookArtist(message.Artist),
|
Artist = new WebhookArtist(message.Artist),
|
||||||
Tracks = trackFiles.SelectMany(x => x.Tracks.Value.Select(y => new WebhookTrack(y)
|
Tracks = trackFiles.SelectMany(x => x.Tracks.Value.Select(y => new WebhookTrack(y)
|
||||||
{
|
{
|
||||||
|
@ -68,9 +68,9 @@ namespace NzbDrone.Core.Notifications.Webhook
|
||||||
|
|
||||||
public override void OnRename(Artist artist)
|
public override void OnRename(Artist artist)
|
||||||
{
|
{
|
||||||
var payload = new WebhookPayload
|
var payload = new WebhookRenamePayload
|
||||||
{
|
{
|
||||||
EventType = "Rename",
|
EventType = WebhookEventType.Rename,
|
||||||
Artist = new WebhookArtist(artist)
|
Artist = new WebhookArtist(artist)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -79,15 +79,29 @@ namespace NzbDrone.Core.Notifications.Webhook
|
||||||
|
|
||||||
public override void OnTrackRetag(TrackRetagMessage message)
|
public override void OnTrackRetag(TrackRetagMessage message)
|
||||||
{
|
{
|
||||||
var payload = new WebhookPayload
|
var payload = new WebhookRetagPayload
|
||||||
{
|
{
|
||||||
EventType = "Retag",
|
EventType = WebhookEventType.Retag,
|
||||||
Artist = new WebhookArtist(message.Artist)
|
Artist = new WebhookArtist(message.Artist)
|
||||||
};
|
};
|
||||||
|
|
||||||
_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()
|
||||||
|
@ -105,7 +119,7 @@ namespace NzbDrone.Core.Notifications.Webhook
|
||||||
{
|
{
|
||||||
var payload = new WebhookGrabPayload
|
var payload = new WebhookGrabPayload
|
||||||
{
|
{
|
||||||
EventType = "Test",
|
EventType = WebhookEventType.Test,
|
||||||
Artist = new WebhookArtist()
|
Artist = new WebhookArtist()
|
||||||
{
|
{
|
||||||
Id = 1,
|
Id = 1,
|
||||||
|
|
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 WebhookArtist Artist { get; set; }
|
||||||
public List<WebhookAlbum> Albums { get; set; }
|
public List<WebhookAlbum> Albums { 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 WebhookArtist Artist { get; set; }
|
||||||
public List<WebhookTrack> Tracks { get; set; }
|
public List<WebhookTrack> Tracks { get; set; }
|
||||||
public List<WebhookTrackFile> TrackFiles { get; set; }
|
public List<WebhookTrackFile> TrackFiles { 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 WebhookArtist Artist { 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…
Add table
Add a link
Reference in a new issue