mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 13:06:50 +00:00
feat: rewrite database schema for localized autoproxy
This commit is contained in:
parent
ca108813b7
commit
982812333b
16 changed files with 245 additions and 188 deletions
|
|
@ -9,15 +9,11 @@ namespace PluralKit.Core;
|
|||
public class SystemGuildPatch: PatchObject
|
||||
{
|
||||
public Partial<bool> ProxyEnabled { get; set; }
|
||||
public Partial<AutoproxyMode> AutoproxyMode { get; set; }
|
||||
public Partial<MemberId?> AutoproxyMember { get; set; }
|
||||
public Partial<string?> Tag { get; set; }
|
||||
public Partial<bool?> TagEnabled { get; set; }
|
||||
|
||||
public override Query Apply(Query q) => q.ApplyPatch(wrapper => wrapper
|
||||
.With("proxy_enabled", ProxyEnabled)
|
||||
.With("autoproxy_mode", AutoproxyMode)
|
||||
.With("autoproxy_member", AutoproxyMember)
|
||||
.With("tag", Tag)
|
||||
.With("tag_enabled", TagEnabled)
|
||||
);
|
||||
|
|
@ -29,24 +25,13 @@ public class SystemGuildPatch: PatchObject
|
|||
}
|
||||
|
||||
#nullable disable
|
||||
public static SystemGuildPatch FromJson(JObject o, MemberId? memberId)
|
||||
public static SystemGuildPatch FromJson(JObject o)
|
||||
{
|
||||
var patch = new SystemGuildPatch();
|
||||
|
||||
if (o.ContainsKey("proxying_enabled") && o["proxying_enabled"].Type != JTokenType.Null)
|
||||
patch.ProxyEnabled = o.Value<bool>("proxying_enabled");
|
||||
|
||||
if (o.ContainsKey("autoproxy_mode"))
|
||||
{
|
||||
var (val, err) = o["autoproxy_mode"].ParseAutoproxyMode();
|
||||
if (err != null)
|
||||
patch.Errors.Add(err);
|
||||
else
|
||||
patch.AutoproxyMode = val.Value;
|
||||
}
|
||||
|
||||
patch.AutoproxyMember = memberId;
|
||||
|
||||
if (o.ContainsKey("tag"))
|
||||
patch.Tag = o.Value<string>("tag").NullIfEmpty();
|
||||
|
||||
|
|
@ -56,7 +41,7 @@ public class SystemGuildPatch: PatchObject
|
|||
return patch;
|
||||
}
|
||||
|
||||
public JObject ToJson(string memberRef, ulong guild_id)
|
||||
public JObject ToJson(ulong guild_id)
|
||||
{
|
||||
var o = new JObject();
|
||||
|
||||
|
|
@ -65,12 +50,6 @@ public class SystemGuildPatch: PatchObject
|
|||
if (ProxyEnabled.IsPresent)
|
||||
o.Add("proxying_enabled", ProxyEnabled.Value);
|
||||
|
||||
if (AutoproxyMode.IsPresent)
|
||||
o.Add("autoproxy_mode", AutoproxyMode.Value.ToString().ToLower());
|
||||
|
||||
if (AutoproxyMember.IsPresent)
|
||||
o.Add("autoproxy_member", memberRef);
|
||||
|
||||
if (Tag.IsPresent)
|
||||
o.Add("tag", Tag.Value);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue