From e435b78e2804fbcb7bef5738ee168b0bbae49601 Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Thu, 21 May 2026 19:13:03 +1200 Subject: [PATCH] Do not revoke newer webhooks --- src/db/migrations/0037-remove-leaked-webhooks.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/db/migrations/0037-remove-leaked-webhooks.js b/src/db/migrations/0037-remove-leaked-webhooks.js index 79fad16..0228053 100644 --- a/src/db/migrations/0037-remove-leaked-webhooks.js +++ b/src/db/migrations/0037-remove-leaked-webhooks.js @@ -18,7 +18,8 @@ module.exports = async function(db) { const affectedChannels = from("message_room").join("historical_channel_room", "historical_room_index") .pluck("reference_channel_id").selectUnsafe("DISTINCT reference_channel_id") .and("WHERE message_id >= ? AND message_id <= ? AND length(message_id) = ?").all(startSnowflake, endSnowflake, startSnowflake.length) - const affectedWebhooks = select("webhook", ["channel_id", "webhook_id", "webhook_token"], {channel_id: affectedChannels}).all() + let affectedWebhooks = select("webhook", ["channel_id", "webhook_id", "webhook_token"], {channel_id: affectedChannels}).all() + affectedWebhooks = affectedWebhooks.filter(w => BigInt(w.webhook_id) < BigInt(endSnowflake)) // if webhook ID is already newly generated then no need to replace if (affectedWebhooks.length) { process.stdout.write(` revoking ${affectedWebhooks.length} possibly compromised webhooks... `)