summary refs log tree commit diff
path: root/src/api
diff options
context:
space:
mode:
authorCyber <cyber.hf18@gmail.com>2025-11-19 15:20:12 +0100
committerGitHub <noreply@github.com>2025-11-19 15:20:12 +0100
commit86f36dcc68ef6eaba229d9533e48956792c6d020 (patch)
treeb52e28f4638ce967f3ba8e8478a73b2f2b9aa0fb /src/api
parentimplement mention_count (diff)
parentMerge pull request #1392 from MathMan05/EmbedFix (diff)
downloadserver-ts-86f36dcc68ef6eaba229d9533e48956792c6d020.tar.xz
Merge branch 'master' into readStates
Diffstat (limited to 'src/api')
-rw-r--r--src/api/util/handlers/Message.ts11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/api/util/handlers/Message.ts b/src/api/util/handlers/Message.ts

index 90d8153e..70bbc479 100644 --- a/src/api/util/handlers/Message.ts +++ b/src/api/util/handlers/Message.ts
@@ -51,6 +51,7 @@ import { ReadState } from "../../../util/entities/ReadState"; import { Member } from "../../../util/entities/Member"; import { ChannelType } from "@spacebar/schemas"; 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 @@ -377,6 +378,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"); @@ -403,10 +409,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",