From bc4847cdc7fb12637f3599c3693d1e9f1476b91a Mon Sep 17 00:00:00 2001 From: Bogdan Date: Wed, 6 Dec 2023 10:51:06 +0200 Subject: [PATCH] New: Improve fields selection for Discord connection --- .../Notifications/Discord/Discord.cs | 4 +- .../Notifications/Discord/DiscordSettings.cs | 56 ++++++++++++++++--- 2 files changed, 51 insertions(+), 9 deletions(-) diff --git a/src/NzbDrone.Core/Notifications/Discord/Discord.cs b/src/NzbDrone.Core/Notifications/Discord/Discord.cs index c35c769b9..f4069d651 100644 --- a/src/NzbDrone.Core/Notifications/Discord/Discord.cs +++ b/src/NzbDrone.Core/Notifications/Discord/Discord.cs @@ -442,7 +442,7 @@ namespace NzbDrone.Core.Notifications.Discord Timestamp = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss.fffZ") }; - if (Settings.ManualInteractionFields.Contains((int)DiscordGrabFieldType.Poster)) + if (Settings.ManualInteractionFields.Contains((int)DiscordManualInteractionFieldType.Poster)) { embed.Thumbnail = new DiscordImage { @@ -450,7 +450,7 @@ namespace NzbDrone.Core.Notifications.Discord }; } - if (Settings.ManualInteractionFields.Contains((int)DiscordGrabFieldType.Fanart)) + if (Settings.ManualInteractionFields.Contains((int)DiscordManualInteractionFieldType.Fanart)) { embed.Image = new DiscordImage { diff --git a/src/NzbDrone.Core/Notifications/Discord/DiscordSettings.cs b/src/NzbDrone.Core/Notifications/Discord/DiscordSettings.cs index c4af59f45..459fdaa2d 100644 --- a/src/NzbDrone.Core/Notifications/Discord/DiscordSettings.cs +++ b/src/NzbDrone.Core/Notifications/Discord/DiscordSettings.cs @@ -19,12 +19,54 @@ namespace NzbDrone.Core.Notifications.Discord public DiscordSettings() { // Set Default Fields - GrabFields = new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }; - ImportFields = new[] { 0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12 }; - ManualInteractionFields = new[] { 0, 1, 2, 3, 5, 6, 7, 8, 9 }; + GrabFields = new[] + { + (int)DiscordGrabFieldType.Overview, + (int)DiscordGrabFieldType.Rating, + (int)DiscordGrabFieldType.Genres, + (int)DiscordGrabFieldType.Quality, + (int)DiscordGrabFieldType.Group, + (int)DiscordGrabFieldType.Size, + (int)DiscordGrabFieldType.Links, + (int)DiscordGrabFieldType.Release, + (int)DiscordGrabFieldType.Poster, + (int)DiscordGrabFieldType.Fanart, + (int)DiscordGrabFieldType.Indexer, + (int)DiscordGrabFieldType.CustomFormats, + (int)DiscordGrabFieldType.CustomFormatScore + }; + ImportFields = new[] + { + (int)DiscordImportFieldType.Overview, + (int)DiscordImportFieldType.Rating, + (int)DiscordImportFieldType.Genres, + (int)DiscordImportFieldType.Quality, + (int)DiscordImportFieldType.Codecs, + (int)DiscordImportFieldType.Group, + (int)DiscordImportFieldType.Size, + (int)DiscordImportFieldType.Languages, + (int)DiscordImportFieldType.Subtitles, + (int)DiscordImportFieldType.Links, + (int)DiscordImportFieldType.Release, + (int)DiscordImportFieldType.Poster, + (int)DiscordImportFieldType.Fanart + }; + ManualInteractionFields = new[] + { + (int)DiscordManualInteractionFieldType.Overview, + (int)DiscordManualInteractionFieldType.Rating, + (int)DiscordManualInteractionFieldType.Genres, + (int)DiscordManualInteractionFieldType.Quality, + (int)DiscordManualInteractionFieldType.Group, + (int)DiscordManualInteractionFieldType.Size, + (int)DiscordManualInteractionFieldType.Links, + (int)DiscordManualInteractionFieldType.DownloadTitle, + (int)DiscordManualInteractionFieldType.Poster, + (int)DiscordManualInteractionFieldType.Fanart + }; } - private static readonly DiscordSettingsValidator Validator = new DiscordSettingsValidator(); + private static readonly DiscordSettingsValidator Validator = new (); [FieldDefinition(0, Label = "Webhook URL", HelpText = "Discord channel webhook url")] public string WebHookUrl { get; set; } @@ -38,13 +80,13 @@ namespace NzbDrone.Core.Notifications.Discord [FieldDefinition(3, Label = "Author", Advanced = true, HelpText = "Override the embed author that shows for this notification, Blank is instance name", Type = FieldType.Textbox)] public string Author { get; set; } - [FieldDefinition(4, Label = "On Grab Fields", Advanced = true, SelectOptions = typeof(DiscordGrabFieldType), HelpText = "Change the fields that are passed in for this 'on grab' notification", Type = FieldType.TagSelect)] + [FieldDefinition(4, Label = "On Grab Fields", Advanced = true, SelectOptions = typeof(DiscordGrabFieldType), HelpText = "Change the fields that are passed in for this 'on grab' notification", Type = FieldType.Select)] public IEnumerable GrabFields { get; set; } - [FieldDefinition(5, Label = "On Import Fields", Advanced = true, SelectOptions = typeof(DiscordImportFieldType), HelpText = "Change the fields that are passed for this 'on import' notification", Type = FieldType.TagSelect)] + [FieldDefinition(5, Label = "On Import Fields", Advanced = true, SelectOptions = typeof(DiscordImportFieldType), HelpText = "Change the fields that are passed for this 'on import' notification", Type = FieldType.Select)] public IEnumerable ImportFields { get; set; } - [FieldDefinition(6, Label = "On Manual Interaction Fields", Advanced = true, SelectOptions = typeof(DiscordManualInteractionFieldType), HelpText = "Change the fields that are passed for this 'on manual interaction' notification", Type = FieldType.TagSelect)] + [FieldDefinition(6, Label = "On Manual Interaction Fields", Advanced = true, SelectOptions = typeof(DiscordManualInteractionFieldType), HelpText = "Change the fields that are passed for this 'on manual interaction' notification", Type = FieldType.Select)] public IEnumerable ManualInteractionFields { get; set; } public NzbDroneValidationResult Validate()