From 184433b0781dbbf40c150d598336545ae5fa5720 Mon Sep 17 00:00:00 2001 From: Zane Helton Date: Sat, 28 Jun 2025 03:17:09 -0400 Subject: [PATCH] Start fresh when updating embeds for links In a previous commit I was attempting to be clever by only replacing/removing embeds if necessary. This not only made the logic more confusing but introduced a bug that would allow for orphaned embeds when updating the search params of a URL. This commit will remove all embeds that have a `.url` property and start fresh. This simplifies the code and eliminates the aforementioned bug. --- src/api/util/handlers/Message.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/api/util/handlers/Message.ts b/src/api/util/handlers/Message.ts index 869f0149..db368d55 100644 --- a/src/api/util/handlers/Message.ts +++ b/src/api/util/handlers/Message.ts @@ -290,18 +290,13 @@ export async function postHandleMessage(message: Message) { } } - // Remove existing embeds whose URLs ARE in the current message (we'll regenerate them) + // Remove ALL embeds that have URLs when processing links (start fresh) data.embeds = data.embeds.filter((embed) => { if (!embed.url) { return true; } - try { - const normalizedEmbedUrl = normalizeUrl(embed.url); - const shouldRemove = currentNormalizedUrls.has(normalizedEmbedUrl); - return !shouldRemove; - } catch { - return true; - } + + return false; }); const seenNormalizedUrls = new Set();