feat(bot): allow separate member avatars for proxied messages (#523)

This allows for using one avatar for the member card, and a different
avatar for proxied messages - so that users can set the main avatar to
a "full" version of their avatar, and the "proxy" avatar to a cropped
version.
This commit is contained in:
the iris system
2023-03-02 06:11:35 +13:00
committed by GitHub
parent 7fffb7f65a
commit ccb89f50e9
12 changed files with 138 additions and 49 deletions

View File

@@ -23,9 +23,9 @@ public class ProxyMember
public string Name { get; } = "";
public string? ServerAvatar { get; }
public string? WebhookAvatar { get; }
public string? Avatar { get; }
public bool AllowAutoproxy { get; }
public string? Color { get; }
@@ -42,5 +42,5 @@ public class ProxyMember
return memberName;
}
public string? ProxyAvatar(MessageContext ctx) => ServerAvatar ?? Avatar ?? ctx.SystemAvatar;
public string? ProxyAvatar(MessageContext ctx) => ServerAvatar ?? WebhookAvatar ?? Avatar ?? ctx.SystemAvatar;
}

View File

@@ -1,4 +1,4 @@
create function message_context(account_id bigint, guild_id bigint, channel_id bigint)
create function message_context(account_id bigint, guild_id bigint, channel_id bigint)
returns table (
system_id int,
log_channel bigint,
@@ -67,6 +67,7 @@ create function proxy_members(account_id bigint, guild_id bigint)
name text,
server_avatar text,
webhook_avatar text,
avatar text,
color char(6),
@@ -76,22 +77,23 @@ create function proxy_members(account_id bigint, guild_id bigint)
as $$
select
-- Basic data
members.id as id,
members.proxy_tags as proxy_tags,
members.keep_proxy as keep_proxy,
members.id as id,
members.proxy_tags as proxy_tags,
members.keep_proxy as keep_proxy,
-- Name info
member_guild.display_name as server_name,
members.display_name as display_name,
members.name as name,
member_guild.display_name as server_name,
members.display_name as display_name,
members.name as name,
-- Avatar info
member_guild.avatar_url as server_avatar,
members.avatar_url as avatar,
member_guild.avatar_url as server_avatar,
members.webhook_avatar_url as webhook_avatar,
members.avatar_url as avatar,
members.color as color,
members.color as color,
members.allow_autoproxy as allow_autoproxy
members.allow_autoproxy as allow_autoproxy
from accounts
inner join systems on systems.id = accounts.system
inner join members on members.system = systems.id

View File

@@ -0,0 +1,6 @@
-- database version 33
-- add webhook_avatar_url to system members
alter table members add column webhook_avatar_url text;
update info set schema_version = 33;

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