mirror of
https://github.com/g3rv4/GetMoarFediverse.git
synced 2024-11-21 15:13:08 +01:00
Fix NRE when Tags is null and error if both tags and connection string are specified (#9)
This commit is contained in:
parent
a88e9f9fd5
commit
518b51fcf6
@ -50,6 +50,12 @@ public class Config
|
||||
Console.WriteLine("Warning: Sites is deprecated, please use Instances instead");
|
||||
}
|
||||
|
||||
data.Tags ??= Array.Empty<string>();
|
||||
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<SiteData> GetImmutableSites()
|
||||
|
8
src/Extensions.cs
Normal file
8
src/Extensions.cs
Normal file
@ -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();
|
||||
}
|
Loading…
Reference in New Issue
Block a user