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:
@@ -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;
|
||||
}
|
@@ -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
|
||||
|
6
PluralKit.Core/Database/Migrations/33.sql
Normal file
6
PluralKit.Core/Database/Migrations/33.sql
Normal 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;
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user