diff --git a/src/Config.cs b/src/Config.cs index 0b23d65..2b1044b 100644 --- a/src/Config.cs +++ b/src/Config.cs @@ -50,6 +50,12 @@ public class Config Console.WriteLine("Warning: Sites is deprecated, please use Instances instead"); } + data.Tags ??= Array.Empty(); + if (data.MastodonPostgresConnectionString.HasValue() && data.Tags.Length > 0) + { + throw new Exception("You can't specify both MastodonPostgresConnectionString and Tags"); + } + Instance = new Config(importedPath, data.FakeRelayUrl, apiKey, data.MastodonPostgresConnectionString, data.Tags.ToImmutableArray(), data.GetImmutableSites()); } @@ -60,7 +66,7 @@ public class Config public string? FakeRelayApiKey { get; set; } public string? MastodonPostgresConnectionString { get; set; } public string[]? Instances { get; set; } - public string[] Tags { get; set; } + public string[]? Tags { get; set; } public InternalSiteData[]? Sites { get; set; } public ImmutableArray GetImmutableSites() diff --git a/src/Extensions.cs b/src/Extensions.cs new file mode 100644 index 0000000..9eed7c5 --- /dev/null +++ b/src/Extensions.cs @@ -0,0 +1,8 @@ +namespace GetMoarFediverse; + +public static class Extensions +{ + public static bool IsNullOrEmpty(this string s) => string.IsNullOrEmpty(s); + + public static bool HasValue(this string s) => !s.IsNullOrEmpty(); +}