summary refs log tree commit diff
path: root/src/api/util
diff options
context:
space:
mode:
authorMathMan05 <mathmanrm@gmail.com>2025-11-19 08:40:09 -0600
committerMathMan05 <mathmanrm@gmail.com>2025-11-19 08:40:09 -0600
commit0490739330bf4ea3b49be9f1c7766ee8ac580b57 (patch)
tree91b46561ed8f39850057e7a75f4c286de34d2f08 /src/api/util
parentget rid of log (diff)
parentMerge branch 'master' into webhookFix (diff)
downloadserver-ts-0490739330bf4ea3b49be9f1c7766ee8ac580b57.tar.xz
Merge branch 'webhookFix' of https://github.com/MathMan05/server into webhookFix
Diffstat (limited to 'src/api/util')
-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 e3d5a99f..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,10 +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) => { - 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",