From 4dbeb170751c9ee51a9fa5ce6cf2f235c08af93f Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Fri, 2 Oct 2020 15:01:42 -0700 Subject: [PATCH] Webhook clearnup/improvements New: Remove episode file properties from episodes in Webhook payload New: Add more information to Webhook payload --- .../Notifications/Webhook/Webhook.cs | 28 +++++++++---------- .../Notifications/Webhook/WebhookEpisode.cs | 5 ---- .../Webhook/WebhookImportPayload.cs | 1 + 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs b/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs index f769d83f9..9e5eef152 100644 --- a/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.IO; using System.Linq; using FluentValidation.Results; using NzbDrone.Core.Tv; @@ -27,13 +28,7 @@ namespace NzbDrone.Core.Notifications.Webhook { EventType = "Grab", Series = new WebhookSeries(message.Series), - Episodes = remoteEpisode.Episodes.ConvertAll(x => new WebhookEpisode(x) - { - // TODO: Stop passing these parameters inside an episode v3 - Quality = quality.Quality.Name, - QualityVersion = quality.Revision.Version, - ReleaseGroup = remoteEpisode.ParsedEpisodeInfo.ReleaseGroup - }), + Episodes = remoteEpisode.Episodes.ConvertAll(x => new WebhookEpisode(x)), Release = new WebhookRelease(quality, remoteEpisode), DownloadClient = message.DownloadClient, DownloadId = message.DownloadId @@ -50,20 +45,23 @@ namespace NzbDrone.Core.Notifications.Webhook { EventType = "Download", Series = new WebhookSeries(message.Series), - Episodes = episodeFile.Episodes.Value.ConvertAll(x => new WebhookEpisode(x) - { - // TODO: Stop passing these parameters inside an episode v3 - Quality = episodeFile.Quality.Quality.Name, - QualityVersion = episodeFile.Quality.Revision.Version, - ReleaseGroup = episodeFile.ReleaseGroup, - SceneName = episodeFile.SceneName - }), + Episodes = episodeFile.Episodes.Value.ConvertAll(x => new WebhookEpisode(x)), EpisodeFile = new WebhookEpisodeFile(episodeFile), IsUpgrade = message.OldFiles.Any(), DownloadClient = message.DownloadClient, DownloadId = message.DownloadId }; + if (message.OldFiles.Any()) + { + payload.DeletedFiles = message.OldFiles.ConvertAll(x => new WebhookEpisodeFile(x) + { + Path = Path.Combine(message.Series.Path, + x.RelativePath) + } + ); + } + _proxy.SendWebhook(payload, Settings); } diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookEpisode.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookEpisode.cs index a7979b726..c6e812d6f 100644 --- a/src/NzbDrone.Core/Notifications/Webhook/WebhookEpisode.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookEpisode.cs @@ -23,10 +23,5 @@ namespace NzbDrone.Core.Notifications.Webhook public string Title { get; set; } public string AirDate { get; set; } public DateTime? AirDateUtc { get; set; } - - public string Quality { get; set; } - public int QualityVersion { get; set; } - public string ReleaseGroup { get; set; } - public string SceneName { get; set; } } } \ No newline at end of file diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookImportPayload.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookImportPayload.cs index f6f516c14..87ba9c423 100644 --- a/src/NzbDrone.Core/Notifications/Webhook/WebhookImportPayload.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookImportPayload.cs @@ -9,5 +9,6 @@ namespace NzbDrone.Core.Notifications.Webhook public bool IsUpgrade { get; set; } public string DownloadClient { get; set; } public string DownloadId { get; set; } + public List DeletedFiles { get; set; } } }