mirror of
https://github.com/g3rv4/GetMoarFediverse.git
synced 2024-11-21 23:23:09 +01:00
Deprecate Sites in favor of Instances (#7)
This commit is contained in:
parent
4ccfaad15f
commit
875b2fe26e
12
README.md
12
README.md
@ -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" ]
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -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
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user