feat: per-server keepproxy toggling (#574)

Merges PluralKit/PluralKit#574
This commit is contained in:
Jake Fulmine 2023-08-10 18:15:25 +12:00 committed by Iris System
parent 8a59ef5f50
commit 22ce250b56
11 changed files with 131 additions and 15 deletions

View file

@ -18,6 +18,7 @@ public class ProxyMember
public IReadOnlyCollection<ProxyTag> ProxyTags { get; } = new ProxyTag[0];
public bool KeepProxy { get; }
public bool Tts { get; }
public bool? ServerKeepProxy { get; }
public string? ServerName { get; }
public string? DisplayName { get; }
@ -44,4 +45,4 @@ public class ProxyMember
}
public string? ProxyAvatar(MessageContext ctx) => ServerAvatar ?? WebhookAvatar ?? Avatar ?? ctx.SystemGuildAvatar ?? ctx.SystemAvatar;
}
}

View file

@ -69,6 +69,7 @@ create function proxy_members(account_id bigint, guild_id bigint)
proxy_tags proxy_tag[],
keep_proxy bool,
tts bool,
server_keep_proxy bool,
server_name text,
display_name text,
@ -89,6 +90,7 @@ as $$
members.proxy_tags as proxy_tags,
members.keep_proxy as keep_proxy,
members.tts as tts,
member_guild.keep_proxy as server_keep_proxy,
-- Name info
member_guild.display_name as server_name,
@ -154,4 +156,4 @@ begin
if not exists (select 1 from groups where hid = new_hid) then return new_hid; end if;
end loop;
end
$$ language plpgsql volatile;
$$ language plpgsql volatile;

View file

@ -0,0 +1,6 @@
-- database version 40
-- add per-server keepproxy toggle
alter table member_guild add column keep_proxy bool default null;
update info set schema_version = 40;

View file

@ -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 = 39;
private const int TargetSchemaVersion = 40;
private readonly ILogger _logger;
public DatabaseMigrator(ILogger logger)