From 7cb3a3ea0fbce348de633090f1f4278942c5631d Mon Sep 17 00:00:00 2001 From: spiral Date: Wed, 15 Jun 2022 18:52:50 -0400 Subject: [PATCH] feat(bot): remove hacky fix for extremely slow system deletes they are no longer extremely slow --- PluralKit.Bot/Handlers/MessageCreated.cs | 13 ------------- PluralKit.Core/Database/Functions/MessageContext.cs | 1 - PluralKit.Core/Database/Functions/functions.sql | 2 -- .../Database/Repository/ModelRepository.System.cs | 1 - 4 files changed, 17 deletions(-) diff --git a/PluralKit.Bot/Handlers/MessageCreated.cs b/PluralKit.Bot/Handlers/MessageCreated.cs index 7f6cd1c0..2150cb50 100644 --- a/PluralKit.Bot/Handlers/MessageCreated.cs +++ b/PluralKit.Bot/Handlers/MessageCreated.cs @@ -117,17 +117,6 @@ public class MessageCreated: IEventHandler if (!HasCommandPrefix(content, ourUserId, out var cmdStart) || cmdStart == content.Length) return false; - if (ctx.IsDeleting) - { - await _rest.CreateMessage(evt.ChannelId, new() - { - Content = $"{Emojis.Error} Your system is currently being deleted." - + " Due to database issues, it is not possible to use commands while a system is being deleted. Please wait a few minutes and try again.", - MessageReference = new(guild?.Id, channel.Id, evt.Id) - }); - return true; - } - // Trim leading whitespace from command without actually modifying the string // This just moves the argPos pointer by however much whitespace is at the start of the post-argPos string var trimStartLengthDiff = @@ -172,8 +161,6 @@ public class MessageCreated: IEventHandler private async ValueTask TryHandleProxy(MessageCreateEvent evt, Guild guild, Channel channel, MessageContext ctx) { - if (ctx.IsDeleting) return false; - var botPermissions = await _cache.PermissionsIn(channel.Id); try diff --git a/PluralKit.Core/Database/Functions/MessageContext.cs b/PluralKit.Core/Database/Functions/MessageContext.cs index a03cb9da..70db64f6 100644 --- a/PluralKit.Core/Database/Functions/MessageContext.cs +++ b/PluralKit.Core/Database/Functions/MessageContext.cs @@ -14,7 +14,6 @@ public class MessageContext /// /// Whether a system is being deleted (no actions should be taken, or commands ran) /// - public bool IsDeleting { get; } public ulong? LogChannel { get; } public bool InBlacklist { get; } public bool InLogBlacklist { get; } diff --git a/PluralKit.Core/Database/Functions/functions.sql b/PluralKit.Core/Database/Functions/functions.sql index bebfd7b3..80445c64 100644 --- a/PluralKit.Core/Database/Functions/functions.sql +++ b/PluralKit.Core/Database/Functions/functions.sql @@ -1,7 +1,6 @@ create function message_context(account_id bigint, guild_id bigint, channel_id bigint) returns table ( system_id int, - is_deleting bool, log_channel bigint, in_blacklist bool, in_log_blacklist bool, @@ -28,7 +27,6 @@ as $$ guild as (select * from servers where id = guild_id) select system.id as system_id, - system.is_deleting, guild.log_channel, (channel_id = any (guild.blacklist)) as in_blacklist, (channel_id = any (guild.log_blacklist)) as in_log_blacklist, diff --git a/PluralKit.Core/Database/Repository/ModelRepository.System.cs b/PluralKit.Core/Database/Repository/ModelRepository.System.cs index 96e554ea..50f26b6e 100644 --- a/PluralKit.Core/Database/Repository/ModelRepository.System.cs +++ b/PluralKit.Core/Database/Repository/ModelRepository.System.cs @@ -144,7 +144,6 @@ public partial class ModelRepository public async Task DeleteSystem(SystemId id) { - await _db.Execute(c => c.QueryAsync("update systems set is_deleting = true where id = @id", new { id = id })); var query = new Query("systems").AsDelete().Where("id", id); await _db.ExecuteQuery(query); _logger.Information("Deleted {SystemId}", id);