invert if

This commit is contained in:
MathMan05
2026-03-04 16:19:03 -06:00
committed by Rory&
parent c16fca64bf
commit e4429e910c

View File

@@ -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}`, {