From 22781b62e67eac47f45eecb09fea64378fddc299 Mon Sep 17 00:00:00 2001 From: Qstick Date: Sat, 25 Feb 2023 12:51:23 -0600 Subject: [PATCH] New: Add Editions to Webhook Payloads --- .../Notifications/Webhook/WebhookBase.cs | 8 +------- .../Notifications/Webhook/WebhookBook.cs | 10 +++++----- .../Webhook/WebhookBookEdition.cs | 20 +++++++++++++++++++ 3 files changed, 26 insertions(+), 12 deletions(-) create mode 100644 src/NzbDrone.Core/Notifications/Webhook/WebhookBookEdition.cs diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookBase.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookBase.cs index a5bab7cd1..4c2770d27 100644 --- a/src/NzbDrone.Core/Notifications/Webhook/WebhookBase.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookBase.cs @@ -28,13 +28,7 @@ public WebhookGrabPayload BuildOnGrabPayload(GrabMessage message) EventType = WebhookEventType.Grab, InstanceName = _configFileProvider.InstanceName, Author = new WebhookAuthor(message.Author), - Books = remoteBook.Books.ConvertAll(x => new WebhookBook(x) - { - // TODO: Stop passing these parameters inside an book v3 - Quality = quality.Quality.Name, - QualityVersion = quality.Revision.Version, - ReleaseGroup = remoteBook.ParsedBookInfo.ReleaseGroup - }), + Books = remoteBook.Books.ConvertAll(x => new WebhookBook(x)), Release = new WebhookRelease(quality, remoteBook), DownloadClient = message.DownloadClientName, DownloadClientType = message.DownloadClientType, diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookBook.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookBook.cs index 0e9e3cdbd..fb9f1b869 100644 --- a/src/NzbDrone.Core/Notifications/Webhook/WebhookBook.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookBook.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Linq; using NzbDrone.Core.Books; namespace NzbDrone.Core.Notifications.Webhook @@ -7,6 +9,7 @@ public class WebhookBook { public WebhookBook() { + Editions = new List(); } public WebhookBook(Book book) @@ -15,16 +18,13 @@ public WebhookBook(Book book) GoodreadsId = book.ForeignBookId; Title = book.Title; ReleaseDate = book.ReleaseDate; + Editions = book.Editions.Value.Select(x => new WebhookBookEdition(x)).ToList(); } public int Id { get; set; } public string GoodreadsId { get; set; } public string Title { get; set; } + public List Editions { get; set; } public DateTime? ReleaseDate { get; set; } - - public string Quality { get; set; } - public int QualityVersion { get; set; } - public string ReleaseGroup { get; set; } - public string SceneName { get; set; } } } diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookBookEdition.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookBookEdition.cs new file mode 100644 index 000000000..80d75aa1b --- /dev/null +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookBookEdition.cs @@ -0,0 +1,20 @@ +using NzbDrone.Core.Books; + +namespace NzbDrone.Core.Notifications.Webhook +{ + public class WebhookBookEdition + { + public WebhookBookEdition(Edition edition) + { + GoodreadsId = edition.ForeignEditionId; + Title = edition.Title; + Asin = edition.Asin; + Isbn13 = edition.Isbn13; + } + + public string Title { get; set; } + public string GoodreadsId { get; set; } + public string Asin { get; set; } + public string Isbn13 { get; set; } + } +}