refactor: all instances of generic 'blacklist' to 'proxy blacklist'

This commit is contained in:
Petal Ladenson 2026-01-12 15:31:23 -07:00
parent 952bb02285
commit 1cb554e9c5
10 changed files with 29 additions and 23 deletions

View file

@ -106,9 +106,9 @@ public partial class CommandTree
public static Command LogEnable = new Command("serverconfig log blacklist remove", "serverconfig log blacklist remove all|<channel> [channel 2] [channel 3...]", "Enables message logging in certain channels");
public static Command LogDisable = new Command("serverconfig log blacklist add", "serverconfig log blacklist add all|<channel> [channel 2] [channel 3...]", "Disables message logging in certain channels");
public static Command LogShow = new Command("serverconfig log blacklist", "serverconfig log blacklist", "Displays the current list of channels where logging is disabled");
public static Command BlacklistShow = new Command("serverconfig proxy blacklist", "serverconfig proxy blacklist", "Displays the current list of channels where message proxying is disabled");
public static Command BlacklistAdd = new Command("serverconfig proxy blacklist add", "serverconfig proxy blacklist add all|<channel> [channel 2] [channel 3...]", "Disables message proxying in certain channels");
public static Command BlacklistRemove = new Command("serverconfig proxy blacklist remove", "serverconfig proxy blacklist remove all|<channel> [channel 2] [channel 3...]", "Enables message proxying in certain channels");
public static Command ProxyBlacklistShow = new Command("serverconfig proxy blacklist", "serverconfig proxy blacklist", "Displays the current list of channels where message proxying is disabled");
public static Command ProxyBlacklistAdd = new Command("serverconfig proxy blacklist add", "serverconfig proxy blacklist add all|<channel> [channel 2] [channel 3...]", "Disables message proxying in certain channels");
public static Command ProxyBlacklistRemove = new Command("serverconfig proxy blacklist remove", "serverconfig proxy blacklist remove all|<channel> [channel 2] [channel 3...]", "Enables message proxying in certain channels");
public static Command ServerConfigLogClean = new Command("serverconfig log cleanup", "serverconfig log cleanup [on|off]", "Toggles whether to clean up other bots' log channels");
public static Command ServerConfigInvalidCommandResponse = new Command("serverconfig invalid command error", "serverconfig invalid command error [on|off]", "Sets whether to show an error message when an unknown command is sent");
public static Command ServerConfigRequireSystemTag = new Command("serverconfig require tag", "serverconfig require tag [on|off]", "Sets whether server users are required to have a system tag on proxied messages");
@ -160,7 +160,7 @@ public partial class CommandTree
ServerConfigLogClean, ServerConfigInvalidCommandResponse, ServerConfigRequireSystemTag,
ServerConfigSuppressNotifications,
LogChannel, LogChannelClear, LogShow, LogDisable, LogEnable,
BlacklistShow, BlacklistAdd, BlacklistRemove
ProxyBlacklistShow, ProxyBlacklistAdd, ProxyBlacklistRemove
};
public static Command[] AutoproxyCommands =
@ -170,5 +170,5 @@ public partial class CommandTree
public static Command[] LogCommands = { LogChannel, LogChannelClear, LogEnable, LogDisable, LogShow };
public static Command[] BlacklistCommands = { BlacklistAdd, BlacklistRemove, BlacklistShow };
public static Command[] ProxyBlacklistCommands = { ProxyBlacklistAdd, ProxyBlacklistRemove, ProxyBlacklistShow };
}

View file

@ -69,11 +69,11 @@ public partial class CommandTree
return ctx.Execute<ServerConfig>(ServerConfigLogClean, m => m.SetLogCleanup(ctx), true);
if (ctx.Match("blacklist", "bl"))
if (ctx.Match("enable", "on", "add", "deny"))
return ctx.Execute<ServerConfig>(BlacklistAdd, m => m.SetProxyBlacklisted(ctx, true), true);
return ctx.Execute<ServerConfig>(ProxyBlacklistAdd, m => m.SetProxyBlacklisted(ctx, true), true);
else if (ctx.Match("disable", "off", "remove", "allow"))
return ctx.Execute<ServerConfig>(BlacklistRemove, m => m.SetProxyBlacklisted(ctx, false), true);
return ctx.Execute<ServerConfig>(ProxyBlacklistRemove, m => m.SetProxyBlacklisted(ctx, false), true);
else if (ctx.Match("list", "show"))
return ctx.Execute<ServerConfig>(BlacklistShow, m => m.ShowProxyBlacklisted(ctx), true);
return ctx.Execute<ServerConfig>(ProxyBlacklistShow, m => m.ShowProxyBlacklisted(ctx), true);
else
return ctx.Reply($"{Emojis.Warn} Blacklist commands have moved to `{ctx.DefaultPrefix}serverconfig`.");
if (ctx.Match("proxy"))
@ -530,7 +530,7 @@ public partial class CommandTree
break;
case "blacklist":
case "bl":
await PrintCommandList(ctx, "channel blacklisting", BlacklistCommands);
await PrintCommandList(ctx, "channel proxy blacklisting", ProxyBlacklistCommands);
break;
case "config":
case "cfg":

View file

@ -73,7 +73,7 @@ public class ServerConfig
items.Add(new(
"proxy blacklist",
"Channels where message proxying is disabled",
ChannelListMessage(ctx.GuildConfig!.Blacklist.Length, "proxy blacklist"),
ChannelListMessage(ctx.GuildConfig!.ProxyBlacklist.Length, "proxy blacklist"),
ChannelListMessage(0, "proxy blacklist")
));
@ -197,7 +197,7 @@ public class ServerConfig
var blacklist = await ctx.Repository.GetGuild(ctx.Guild.Id);
// Resolve all channels from the cache and order by position
var channels = (await Task.WhenAll(blacklist.Blacklist
var channels = (await Task.WhenAll(blacklist.ProxyBlacklist
.Select(id => _cache.TryGetChannel(ctx.Guild.Id, id))))
.Where(c => c != null)
.OrderBy(c => c.Position)
@ -314,13 +314,13 @@ public class ServerConfig
var guild = await ctx.Repository.GetGuild(ctx.Guild.Id);
var blacklist = guild.Blacklist.ToHashSet();
var blacklist = guild.ProxyBlacklist.ToHashSet();
if (shouldAdd)
blacklist.UnionWith(affectedChannels.Select(c => c.Id));
else
blacklist.ExceptWith(affectedChannels.Select(c => c.Id));
await ctx.Repository.UpdateGuild(ctx.Guild.Id, new GuildPatch { Blacklist = blacklist.ToArray() });
await ctx.Repository.UpdateGuild(ctx.Guild.Id, new GuildPatch { ProxyBlacklist = blacklist.ToArray() });
await ctx.Reply(
$"{Emojis.Success} Channels {(shouldAdd ? "added to" : "removed from")} the proxy blacklist.");

View file

@ -184,7 +184,7 @@ public class ProxyService
throw new ProxyChecksFailedException("This message is the initial message in a forum post, which PluralKit is unable to proxy correctly.");
// Make sure proxying is enabled here
if (ctx.InBlacklist)
if (ctx.InProxyBlacklist)
throw new ProxyChecksFailedException(
"Proxying was disabled in this channel by a server administrator (via the proxy blacklist).");
@ -290,7 +290,7 @@ public class ProxyService
await _repo.GetMessageContext(msg.Sender, msg.Guild!.Value, rootChannel.Id, msg.Channel);
// Make sure proxying is enabled here
if (ctx.InBlacklist)
if (ctx.InProxyBlacklist)
throw new ProxyChecksFailedException(
"Proxying was disabled in this channel by a server administrator (via the proxy blacklist).");

View file

@ -32,7 +32,7 @@ public class MessageContext
public Instant? LastSwitchTimestamp { get; }
public ulong? LogChannel { get; }
public bool InBlacklist { get; }
public bool InProxyBlacklist { get; }
public bool InLogBlacklist { get; }
public bool LogCleanupEnabled { get; }
public bool RequireSystemTag { get; }

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

View file

@ -5,7 +5,7 @@ public class GuildConfig
public ulong Id { get; }
public ulong? LogChannel { get; }
public ulong[] LogBlacklist { get; }
public ulong[] Blacklist { get; }
public ulong[] ProxyBlacklist { get; }
public bool LogCleanupEnabled { get; }
public bool InvalidCommandResponseEnabled { get; }
public bool RequireSystemTag { get; }

View file

@ -6,7 +6,7 @@ public class GuildPatch: PatchObject
{
public Partial<ulong?> LogChannel { get; set; }
public Partial<ulong[]> LogBlacklist { get; set; }
public Partial<ulong[]> Blacklist { get; set; }
public Partial<ulong[]> ProxyBlacklist { get; set; }
public Partial<bool> LogCleanupEnabled { get; set; }
public Partial<bool> InvalidCommandResponseEnabled { get; set; }
public Partial<bool> RequireSystemTag { get; set; }
@ -15,7 +15,7 @@ public class GuildPatch: PatchObject
public override Query Apply(Query q) => q.ApplyPatch(wrapper => wrapper
.With("log_channel", LogChannel)
.With("log_blacklist", LogBlacklist)
.With("blacklist", Blacklist)
.With("proxy_blacklist", ProxyBlacklist)
.With("log_cleanup_enabled", LogCleanupEnabled)
.With("invalid_command_response_enabled", InvalidCommandResponseEnabled)
.With("require_system_tag", RequireSystemTag)

View file

@ -23,7 +23,7 @@ create function message_context(account_id bigint, guild_id bigint, channel_id b
last_switch_timestamp timestamp,
log_channel bigint,
in_blacklist bool,
in_proxy_blacklist bool,
in_log_blacklist bool,
log_cleanup_enabled bool,
require_system_tag bool,
@ -62,8 +62,8 @@ as $$
-- servers table
servers.log_channel as log_channel,
((channel_id = any (servers.blacklist))
or (thread_id = any (servers.blacklist))) as in_blacklist,
((channel_id = any (servers.proxy_blacklist))
or (thread_id = any (servers.proxy_blacklist))) as in_proxy_blacklist,
((channel_id = any (servers.log_blacklist))
or (thread_id = any (servers.log_blacklist))) as in_log_blacklist,
coalesce(servers.log_cleanup_enabled, false) as log_cleanup_enabled,

View file

@ -0,0 +1,6 @@
-- database version 54
-- rename blacklist column to proxy blacklist
alter table servers rename column blacklist to proxy_blacklist;
update info set schema_version = 54;