From 4b14bae282d1fb8203522db18dae48ee48b07dba Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Tue, 18 Nov 2025 15:17:38 -0600 Subject: [PATCH 1/3] fix --- src/api/util/handlers/Message.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/api/util/handlers/Message.ts b/src/api/util/handlers/Message.ts index e3d5a99f..49cfa30b 100644 --- a/src/api/util/handlers/Message.ts +++ b/src/api/util/handlers/Message.ts @@ -349,7 +349,7 @@ export async function postHandleMessage(message: Message) { } // Filter out embeds that could be links, start from scratch - data.embeds = data.embeds.filter((embed) => embed.type === "rich"); + data.embeds = data.embeds.filter((embed) => embed.type !== "rich"); const seenNormalizedUrls = new Set(); const uniqueLinks: string[] = []; @@ -374,10 +374,7 @@ export async function postHandleMessage(message: Message) { if (uniqueLinks.length === 0) { // No valid unique links found, update message to remove old embeds - data.embeds = data.embeds.filter((embed) => { - const hasUrl = !!embed.url; - return !hasUrl; - }); + data.embeds = data.embeds.filter((embed) => embed.type !== "rich"); const author = data.author?.toPublicUser(); const event = { event: "MESSAGE_UPDATE", From 9db3e4a616be12edf38aafe3c564fbdeb0eb46bd Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Tue, 18 Nov 2025 15:42:17 -0600 Subject: [PATCH 2/3] I am an idiot, it wasn't backwards --- src/api/util/handlers/Message.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/util/handlers/Message.ts b/src/api/util/handlers/Message.ts index 49cfa30b..e2dd71ec 100644 --- a/src/api/util/handlers/Message.ts +++ b/src/api/util/handlers/Message.ts @@ -349,7 +349,7 @@ export async function postHandleMessage(message: Message) { } // Filter out embeds that could be links, start from scratch - data.embeds = data.embeds.filter((embed) => embed.type !== "rich"); + data.embeds = data.embeds.filter((embed) => embed.type === "rich"); const seenNormalizedUrls = new Set(); const uniqueLinks: string[] = []; From afa636396101d20edc13cf3641acd6355f277a2a Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Tue, 18 Nov 2025 15:59:46 -0600 Subject: [PATCH 3/3] more fix --- src/api/util/handlers/Message.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/api/util/handlers/Message.ts b/src/api/util/handlers/Message.ts index e2dd71ec..f558a8b1 100644 --- a/src/api/util/handlers/Message.ts +++ b/src/api/util/handlers/Message.ts @@ -48,6 +48,7 @@ import { In } from "typeorm"; import fetch from "node-fetch-commonjs"; import { CloudAttachment } from "../../../util/entities/CloudAttachment"; import { Embed, MessageCreateAttachment, MessageCreateCloudAttachment, MessageCreateSchema, MessageType, Reaction } from "@spacebar/schemas"; +import { EmbedType } from "../../../schemas/api/messages/Embeds"; const allow_empty = false; // TODO: check webhook, application, system author, stickers // TODO: embed gifs/videos/images @@ -348,6 +349,11 @@ export async function postHandleMessage(message: Message) { } } + data.embeds.forEach((embed) => { + if (!embed.type) { + embed.type = EmbedType.rich; + } + }); // Filter out embeds that could be links, start from scratch data.embeds = data.embeds.filter((embed) => embed.type === "rich"); @@ -374,7 +380,7 @@ export async function postHandleMessage(message: Message) { if (uniqueLinks.length === 0) { // No valid unique links found, update message to remove old embeds - data.embeds = data.embeds.filter((embed) => embed.type !== "rich"); + data.embeds = data.embeds.filter((embed) => embed.type === "rich"); const author = data.author?.toPublicUser(); const event = { event: "MESSAGE_UPDATE",