New: (Discord) Add size grab field and improve field selection

pull/1947/head
Bogdan 6 months ago
parent 67355ec07b
commit e5d7a21714

@ -65,6 +65,11 @@ namespace NzbDrone.Core.Notifications.Discord
discordField.Name = "Host"; discordField.Name = "Host";
discordField.Value = message.Host ?? string.Empty; discordField.Value = message.Host ?? string.Empty;
break; break;
case DiscordGrabFieldType.Size:
discordField.Name = "Size";
discordField.Value = BytesToString(message.Release.Size.GetValueOrDefault(0));
discordField.Inline = true;
break;
} }
if (discordField.Name.IsNotNullOrWhiteSpace() && discordField.Value.IsNotNullOrWhiteSpace()) if (discordField.Name.IsNotNullOrWhiteSpace() && discordField.Value.IsNotNullOrWhiteSpace())

@ -7,6 +7,7 @@ namespace NzbDrone.Core.Notifications.Discord
DownloadClient, DownloadClient,
GrabTrigger, GrabTrigger,
Source, Source,
Host Host,
Size
} }
} }

@ -19,10 +19,19 @@ namespace NzbDrone.Core.Notifications.Discord
public DiscordSettings() public DiscordSettings()
{ {
//Set Default Fields //Set Default Fields
GrabFields = new List<int> { 0, 1, 2, 3, 5, 6, 7, 8, 9 }; GrabFields = new List<int>
{
(int)DiscordGrabFieldType.Release,
(int)DiscordGrabFieldType.Indexer,
(int)DiscordGrabFieldType.DownloadClient,
(int)DiscordGrabFieldType.GrabTrigger,
(int)DiscordGrabFieldType.Source,
(int)DiscordGrabFieldType.Host,
(int)DiscordGrabFieldType.Size
};
} }
private static readonly DiscordSettingsValidator Validator = new DiscordSettingsValidator(); private static readonly DiscordSettingsValidator Validator = new ();
[FieldDefinition(0, Label = "Webhook URL", HelpText = "Discord channel webhook url")] [FieldDefinition(0, Label = "Webhook URL", HelpText = "Discord channel webhook url")]
public string WebHookUrl { get; set; } public string WebHookUrl { get; set; }
@ -36,7 +45,7 @@ namespace NzbDrone.Core.Notifications.Discord
[FieldDefinition(3, Label = "Host", Advanced = true, HelpText = "Override the Host that shows for this notification, Blank is machine name", Type = FieldType.Textbox)] [FieldDefinition(3, Label = "Host", Advanced = true, HelpText = "Override the Host that shows for this notification, Blank is machine name", Type = FieldType.Textbox)]
public string Author { get; set; } 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<int> GrabFields { get; set; } public IEnumerable<int> GrabFields { get; set; }
public NzbDroneValidationResult Validate() public NzbDroneValidationResult Validate()

Loading…
Cancel
Save