aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2024-10-28 18:35:52 -0500
committerJP Dillingham <jp@dillingham.me>2024-10-28 18:35:52 -0500
commite21eb94376f242145b07b49c923f2f997d83611c (patch)
treebc31b1f20ecba3b423a5cf52f54450a87449a6ba /src
parent5ebb679f4f7a24649e5117931e06138a9375110f (diff)
downloadslskd-e21eb94376f242145b07b49c923f2f997d83611c.tar.gz
stub webhook configuration
Diffstat (limited to 'src')
-rw-r--r--src/slskd/Core/Options.cs66
1 files changed, 66 insertions, 0 deletions
diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs
index 306f9b87..cca24ee9 100644
--- a/src/slskd/Core/Options.cs
+++ b/src/slskd/Core/Options.cs
@@ -2006,6 +2006,12 @@ namespace slskd
public class IntegrationOptions
{
/// <summary>
+ /// Gets webhook configuration.
+ /// </summary>
+ [Validate]
+ public Dictionary<string, WebhookOptions> Webhooks { get; init; } = [];
+
+ /// <summary>
/// Gets script configuration.
/// </summary>
[Validate]
@@ -2024,6 +2030,66 @@ namespace slskd
public PushbulletOptions Pushbullet { get; init; } = new PushbulletOptions();
/// <summary>
+ /// Webhook configuration.
+ /// </summary>
+ public class WebhookOptions
+ {
+ /// <summary>
+ /// Gets the list of Event types that trigger the webhook.
+ /// </summary>
+ [Enum(typeof(EventType))]
+ public string[] On { get; init; } = Array.Empty<string>();
+
+ /// <summary>
+ /// Gets details about the webhook call.
+ /// </summary>
+ [Validate]
+ public WebhookDetails Call { get; init; } = new WebhookDetails();
+ }
+
+ /// <summary>
+ /// Webhook details.
+ /// </summary>
+ public class WebhookDetails : IValidatableObject
+ {
+ /// <summary>
+ /// Gets the fully qualified URL for the webhook.
+ /// </summary>
+ [NotNullOrWhiteSpace]
+ public string Url { get; init; }
+
+ /// <summary>
+ /// Gets the HTTP headers to include with the webhook.
+ /// </summary>
+ [Validate]
+ public IEnumerable<WebhookDetailHeader> Headers { get; init; } = [];
+
+ /// <summary>
+ /// Gets a value indicating whether HTTPS certificate errors should be ignored.
+ /// </summary>
+ public bool IgnoreCertificateErrors { get; init; } = false;
+
+ public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
+ {
+ var results = new List<ValidationResult>();
+
+ if (!Url.StartsWith("http://", StringComparison.OrdinalIgnoreCase) && !Url.StartsWith("https://", StringComparison.OrdinalIgnoreCase))
+ {
+ results.Add(new ValidationResult($"The {nameof(Url)} field must contain a fully qualified URL, including protocol (e.g. http:// or https://)"));
+ }
+
+ return results;
+ }
+ }
+
+ public class WebhookDetailHeader
+ {
+ [NotNullOrWhiteSpace]
+ public string Name { get; init; }
+ public string Value { get; init; }
+ }
+
+ /// <summary>
/// Script configuration.
/// </summary>
public class ScriptOptions