fix(bot): make proxy/log blacklists work properly with threads

Handling of both blacklists was inconsistent when dealing with threads:
- proxy blacklist of root channel blacklists all threads
- log blacklist of root channel _did not apply_ to threads
- couldn't proxy blacklist threads while leaving root channel proxyable

This change fixes the inconsistencies:
- proxy _and_ log blacklist of root channel affects all threads
- now able to individually proxy/log blacklist threads, with root
  channel unaffected
This commit is contained in:
Iris System
2023-05-10 13:16:16 +12:00
parent 24f0fcd563
commit 66544b9d40
7 changed files with 34 additions and 26 deletions

View File

@@ -55,6 +55,7 @@ public class MessageEdited: IEventHandler<MessageUpdateEvent>
var channel = await _cache.GetChannel(evt.ChannelId);
if (!DiscordUtils.IsValidGuildChannel(channel))
return;
var rootChannel = await _cache.GetRootChannel(channel.Id);
var guild = await _cache.GetGuild(channel.GuildId!.Value);
var lastMessage = _lastMessageCache.GetLastMessage(evt.ChannelId)?.Current;
@@ -65,7 +66,7 @@ public class MessageEdited: IEventHandler<MessageUpdateEvent>
// Just run the normal message handling code, with a flag to disable autoproxying
MessageContext ctx;
using (_metrics.Measure.Timer.Time(BotMetrics.MessageContextQueryTime))
ctx = await _repo.GetMessageContext(evt.Author.Value!.Id, channel.GuildId!.Value, evt.ChannelId);
ctx = await _repo.GetMessageContext(evt.Author.Value!.Id, channel.GuildId!.Value, rootChannel.Id, evt.ChannelId);
var equivalentEvt = await GetMessageCreateEvent(evt, lastMessage, channel);
var botPermissions = await _cache.PermissionsIn(channel.Id);