summary refs log tree commit diff
diff options
context:
space:
mode:
authorMathMan05 <mathmanrm@gmail.com>2026-03-04 16:19:03 -0600
committerRory& <root@rory.gay>2026-03-20 16:31:32 +0100
commite4429e910ca40d661fe5148f3fed71429dd35e7a (patch)
tree180324bd86ca3e87267636b43246d3d4f783bd43
parentthat shouldn't exist (diff)
downloadserver-ts-e4429e910ca40d661fe5148f3fed71429dd35e7a.tar.xz
invert if
-rw-r--r--src/api/util/handlers/Message.ts14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/api/util/handlers/Message.ts b/src/api/util/handlers/Message.ts

index c59e403a..019fb4c0 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}`, {