mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
feat: alternate proxy switch mode "add" (#702)
* feat: alternate proxy switch mode "add" * docs: add proxy switch add to docs * chore: change default alias to proxy switch new from proxy switch on
This commit is contained in:
parent
e44d813b73
commit
6043d31b08
11 changed files with 76 additions and 19 deletions
|
|
@ -34,6 +34,6 @@ public class MessageContext
|
|||
public int? LatchTimeout { get; }
|
||||
public bool CaseSensitiveProxyTags { get; }
|
||||
public bool ProxyErrorMessageEnabled { get; }
|
||||
public bool ProxySwitch { get; }
|
||||
public SystemConfig.ProxySwitchAction ProxySwitch { get; }
|
||||
public bool DenyBotUsage { get; }
|
||||
}
|
||||
|
|
@ -9,7 +9,7 @@ create function message_context(account_id bigint, guild_id bigint, channel_id b
|
|||
latch_timeout integer,
|
||||
case_sensitive_proxy_tags bool,
|
||||
proxy_error_message_enabled bool,
|
||||
proxy_switch bool,
|
||||
proxy_switch int,
|
||||
name_format text,
|
||||
|
||||
tag_enabled bool,
|
||||
|
|
|
|||
11
PluralKit.Core/Database/Migrations/50.sql
Normal file
11
PluralKit.Core/Database/Migrations/50.sql
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
-- database version 50
|
||||
-- change proxy switch config to an enum
|
||||
|
||||
alter table system_config
|
||||
alter column proxy_switch drop default,
|
||||
alter column proxy_switch type int
|
||||
using case when proxy_switch then 1 else 0 end,
|
||||
alter column proxy_switch set default 0,
|
||||
add constraint proxy_switch_check check (proxy_switch = ANY (ARRAY[0,1,2]));
|
||||
|
||||
update info set schema_version = 50;
|
||||
|
|
@ -9,7 +9,7 @@ namespace PluralKit.Core;
|
|||
internal class DatabaseMigrator
|
||||
{
|
||||
private const string RootPath = "PluralKit.Core.Database"; // "resource path" root for SQL files
|
||||
private const int TargetSchemaVersion = 49;
|
||||
private const int TargetSchemaVersion = 50;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public DatabaseMigrator(ILogger logger)
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ public class SystemConfigPatch: PatchObject
|
|||
public Partial<bool> HidDisplayCaps { get; set; }
|
||||
public Partial<string?> NameFormat { get; set; }
|
||||
public Partial<SystemConfig.HidPadFormat> HidListPadding { get; set; }
|
||||
public Partial<bool> ProxySwitch { get; set; }
|
||||
public Partial<SystemConfig.ProxySwitchAction> ProxySwitch { get; set; }
|
||||
|
||||
public override Query Apply(Query q) => q.ApplyPatch(wrapper => wrapper
|
||||
.With("ui_tz", UiTz)
|
||||
|
|
@ -107,7 +107,7 @@ public class SystemConfigPatch: PatchObject
|
|||
o.Add("hid_list_padding", HidListPadding.Value.ToUserString());
|
||||
|
||||
if (ProxySwitch.IsPresent)
|
||||
o.Add("proxy_switch", ProxySwitch.Value);
|
||||
o.Add("proxy_switch", ProxySwitch.Value.ToUserString());
|
||||
|
||||
if (NameFormat.IsPresent)
|
||||
o.Add("name_format", NameFormat.Value);
|
||||
|
|
@ -150,7 +150,7 @@ public class SystemConfigPatch: PatchObject
|
|||
patch.HidDisplayCaps = o.Value<bool>("hid_display_caps");
|
||||
|
||||
if (o.ContainsKey("proxy_switch"))
|
||||
patch.ProxySwitch = o.Value<bool>("proxy_switch");
|
||||
patch.ProxySwitch = o.Value<SystemConfig.ProxySwitchAction>("proxy_switch");
|
||||
|
||||
if (o.ContainsKey("name_format"))
|
||||
patch.NameFormat = o.Value<string>("name_format");
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ public class SystemConfig
|
|||
public bool HidDisplaySplit { get; }
|
||||
public bool HidDisplayCaps { get; }
|
||||
public HidPadFormat HidListPadding { get; }
|
||||
public bool ProxySwitch { get; }
|
||||
public ProxySwitchAction ProxySwitch { get; }
|
||||
public string NameFormat { get; }
|
||||
|
||||
public enum HidPadFormat
|
||||
|
|
@ -33,6 +33,12 @@ public class SystemConfig
|
|||
Left = 1,
|
||||
Right = 2,
|
||||
}
|
||||
public enum ProxySwitchAction
|
||||
{
|
||||
Off = 0,
|
||||
New = 1,
|
||||
Add = 2,
|
||||
}
|
||||
}
|
||||
|
||||
public static class SystemConfigExt
|
||||
|
|
@ -54,7 +60,7 @@ public static class SystemConfigExt
|
|||
o.Add("hid_display_split", cfg.HidDisplaySplit);
|
||||
o.Add("hid_display_caps", cfg.HidDisplayCaps);
|
||||
o.Add("hid_list_padding", cfg.HidListPadding.ToUserString());
|
||||
o.Add("proxy_switch", cfg.ProxySwitch);
|
||||
o.Add("proxy_switch", cfg.ProxySwitch.ToUserString());
|
||||
o.Add("name_format", cfg.NameFormat);
|
||||
|
||||
o.Add("description_templates", JArray.FromObject(cfg.DescriptionTemplates));
|
||||
|
|
@ -67,4 +73,7 @@ public static class SystemConfigExt
|
|||
if (val == SystemConfig.HidPadFormat.None) return "off";
|
||||
return val.ToString().ToLower();
|
||||
}
|
||||
|
||||
public static string ToUserString(this SystemConfig.ProxySwitchAction val) => val.ToString().ToLower();
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue