From e4429e910ca40d661fe5148f3fed71429dd35e7a Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Wed, 4 Mar 2026 16:19:03 -0600 Subject: [PATCH] invert if --- src/api/util/handlers/Message.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/api/util/handlers/Message.ts b/src/api/util/handlers/Message.ts index c59e403a7..019fb4c0e 100644 --- a/src/api/util/handlers/Message.ts +++ b/src/api/util/handlers/Message.ts @@ -113,7 +113,13 @@ async function processMedia(media: UnfurledMediaItem, messageId: string, batchId if (!["http:", "https:", "attachment:"].includes(url.protocol)) throw new HTTPError("invalid media protocol"); let attEnt: CloudAttachment; let delWhenDone = false; - if (url.protocol !== "attachment") { + if (url.protocol === "attachment") { + attEnt = await CloudAttachment.findOneOrFail({ + where: { + uploadFilename: url.hostname, + }, + }); + } else { const res = await fetch(url); if (!res.ok) throw new HTTPError("URL did not return OK"); const blob = await res.blob(); @@ -144,12 +150,6 @@ async function processMedia(media: UnfurledMediaItem, messageId: string, batchId }, }); delWhenDone = true; - } else { - attEnt = await CloudAttachment.findOneOrFail({ - where: { - uploadFilename: url.hostname, - }, - }); } const cloneResponse = await fetch(`${Config.get().cdn.endpointPrivate}/attachments/${attEnt.uploadFilename}/clone_to_message/${messageId}`, {