aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJP Dillingham <jpdillingham@gmail.com>2021-07-05 14:19:55 -0500
committerJP Dillingham <jpdillingham@gmail.com>2021-07-05 14:19:55 -0500
commit98c86cc81271a61d9c0f2f41072c8a0e7da5eb8f (patch)
tree9b2e36f5b232cd8c92b536c70b42f1f9307f4b49
parent74b96901a1cc4919b81c2c2a5d11de00f43e9648 (diff)
downloadslskd-98c86cc81271a61d9c0f2f41072c8a0e7da5eb8f.tar.gz
validate AccessToken when Enabled
-rw-r--r--src/slskd/Options.cs14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/slskd/Options.cs b/src/slskd/Options.cs
index d2f2ddef..7c697b43 100644
--- a/src/slskd/Options.cs
+++ b/src/slskd/Options.cs
@@ -686,7 +686,7 @@ namespace slskd
/// <summary>
/// Pushbullet options.
/// </summary>
- public class PushbulletOptions
+ public class PushbulletOptions : IValidatableObject
{
/// <summary>
/// Gets a value indicating whether the Pushbullet integration is enabled.
@@ -745,6 +745,18 @@ namespace slskd
[EnvironmentVariable("PUSHBULLET_COOLDOWN_TIME")]
[Description("cooldown time for Pushbullet notifications, in milliseconds")]
public int CooldownTime { get; private set; } = 900000; // 15 minutes
+
+ public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
+ {
+ var results = new List<ValidationResult>();
+
+ if (Enabled && string.IsNullOrWhiteSpace(AccessToken))
+ {
+ results.Add(new ValidationResult($"The Enabled field is true, but no AccessToken has been specified."));
+ }
+
+ return results;
+ }
}
}
}