Skip to content

Commit

Permalink
New: (Discord) Add size grab field and improve field selection
Browse files Browse the repository at this point in the history
  • Loading branch information
mynameisbogdan committed Dec 6, 2023
1 parent 67355ec commit e5d7a21
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/NzbDrone.Core/Notifications/Discord/Discord.cs
Expand Up @@ -65,6 +65,11 @@ public override void OnGrab(GrabMessage message)
discordField.Name = "Host";
discordField.Value = message.Host ?? string.Empty;
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())
Expand Down
3 changes: 2 additions & 1 deletion src/NzbDrone.Core/Notifications/Discord/DiscordFieldType.cs
Expand Up @@ -7,6 +7,7 @@ public enum DiscordGrabFieldType
DownloadClient,
GrabTrigger,
Source,
Host
Host,
Size
}
}
15 changes: 12 additions & 3 deletions src/NzbDrone.Core/Notifications/Discord/DiscordSettings.cs
Expand Up @@ -19,10 +19,19 @@ public class DiscordSettings : IProviderConfig
public DiscordSettings()
{
//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")]
public string WebHookUrl { get; set; }
Expand All @@ -36,7 +45,7 @@ public DiscordSettings()
[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; }

[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 NzbDroneValidationResult Validate()
Expand Down

0 comments on commit e5d7a21

Please sign in to comment.