feat: refactor external input handling code

- refactor import/export code
- make import/export use the same JSON parsing as API
- make Patch.AssertIsValid actually useful
This commit is contained in:
spiral
2021-08-25 21:43:31 -04:00
parent f912805ecc
commit 4b944e2b20
18 changed files with 619 additions and 694 deletions

View File

@@ -102,7 +102,7 @@ namespace PluralKit.Core {
public static int MessageCountFor(this PKMember member, LookupContext ctx) =>
member.MetadataPrivacy.Get(ctx, member.MessageCount);
public static JObject ToJson(this PKMember member, LookupContext ctx)
public static JObject ToJson(this PKMember member, LookupContext ctx, bool needsLegacyProxyTags = false)
{
var includePrivacy = ctx == LookupContext.ByOwner;
@@ -138,7 +138,7 @@ namespace PluralKit.Core {
o.Add("created", member.CreatedFor(ctx)?.FormatExport());
if (member.ProxyTags.Count > 0)
if (member.ProxyTags.Count > 0 && needsLegacyProxyTags)
{
// Legacy compatibility only, TODO: remove at some point
o.Add("prefix", member.ProxyTags?.FirstOrDefault().Prefix);