Deprecate Sites in favor of Instances (#7)

This commit is contained in:
Gervasio Marchand 2022-12-20 12:03:06 -08:00 committed by GitHub
parent 4ccfaad15f
commit 875b2fe26e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 15 deletions

View File

@ -18,17 +18,7 @@ You can download an executable for your environment [on the releases page](https
"dotnet",
"csharp"
],
"Sites": [
{
"Host": "hachyderm.io",
"SiteSpecificTags": [
"hachyderm"
]
},
{
"Host": "mastodon.social"
}
]
"Instances": [ "hachyderm.io", "mastodon.social" ]
}
```

View File

@ -45,8 +45,13 @@ public class Config
throw new Exception("The api key is missing");
}
if (data.Sites is { Length: > 0 })
{
Console.WriteLine("Warning: Sites is deprecated, please use Instances instead");
}
Instance = new Config(importedPath, data.FakeRelayUrl, apiKey, data.MastodonPostgresConnectionString,
data.Tags.ToImmutableArray(), data.ImmutableSites);
data.Tags.ToImmutableArray(), data.GetImmutableSites());
}
public class ConfigData
@ -54,14 +59,26 @@ public class Config
public string FakeRelayUrl { get; set; }
public string? FakeRelayApiKey { get; set; }
public string? MastodonPostgresConnectionString { get; set; }
public string[]? Instances { get; set; }
public string[] Tags { get; set; }
public InternalSiteData[]? Sites { get; set; }
public ImmutableArray<SiteData> ImmutableSites =>
Sites == null
public ImmutableArray<SiteData> GetImmutableSites()
{
// the plan is to stop supporting Sites in favor of Instances. SiteSpecificTags add complexity and
// don't make sense when pulling tags from Mastodon. Also, pulling is fast and multithreaded!
if (Instances != null)
{
return Instances
.Select(i => new SiteData { Host = i, SiteSpecificTags = ImmutableArray<string>.Empty })
.ToImmutableArray();
}
return Sites == null
? ImmutableArray<SiteData>.Empty
: Sites.Select(s => s.ToSiteData())
.ToImmutableArray();
.ToImmutableArray();
}
public class InternalSiteData
{