summary refs log tree commit diff
path: root/src/api
diff options
context:
space:
mode:
authorZane Helton <zane99@me.com>2025-06-28 03:17:09 -0400
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2025-06-28 18:30:52 +1000
commit184433b0781dbbf40c150d598336545ae5fa5720 (patch)
tree7462d29f4e5c325c9e824b64bba6c60d0a4084fc /src/api
parentFix various issues with embeds on message updates (diff)
downloadserver-ts-184433b0781dbbf40c150d598336545ae5fa5720.tar.xz
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.
Diffstat (limited to 'src/api')
-rw-r--r--src/api/util/handlers/Message.ts11
1 files 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<string>();