summary refs log tree commit diff
path: root/src/api
diff options
context:
space:
mode:
authorMathMan05 <mathmanrm@gmail.com>2026-02-26 14:51:11 -0600
committerRory& <root@rory.gay>2026-03-07 00:58:31 +0100
commit5113b97bbc46a357992eb8d38cb18d8d46104f7a (patch)
tree94721a98e8a3b8376c5ce08334dc2adfac5fa277 /src/api
parentmaybe processing media? (diff)
downloadserver-ts-5113b97bbc46a357992eb8d38cb18d8d46104f7a.tar.xz
sign 'em
Diffstat (limited to 'src/api')
-rw-r--r--src/api/routes/channels/#channel_id/messages/index.ts14
-rw-r--r--src/api/util/handlers/Message.ts14
2 files changed, 18 insertions, 10 deletions
diff --git a/src/api/routes/channels/#channel_id/messages/index.ts b/src/api/routes/channels/#channel_id/messages/index.ts

index 46ef45f0..38939bb4 100644 --- a/src/api/routes/channels/#channel_id/messages/index.ts +++ b/src/api/routes/channels/#channel_id/messages/index.ts
@@ -510,15 +510,11 @@ router.post( // no await as it shouldnt block the message send function and silently catch error postHandleMessage(message).catch((e) => console.error("[Message] post-message handler failed", e)); - - return res.json( - message.withSignedAttachments( - new NewUrlUserSignatureData({ - ip: req.ip, - userAgent: req.headers["user-agent"] as string, - }), - ), - ); + const sign = new NewUrlUserSignatureData({ + ip: req.ip, + userAgent: req.headers["user-agent"] as string, + }); + return res.json(await Message.prototype.withSignedComponents.call(message.withSignedAttachments(sign), sign)); }, ); diff --git a/src/api/util/handlers/Message.ts b/src/api/util/handlers/Message.ts
index f73b62fb..94d46998 100644 --- a/src/api/util/handlers/Message.ts +++ b/src/api/util/handlers/Message.ts
@@ -163,8 +163,20 @@ async function processMedia(media: UnfurledMediaItem, messageId: string, batchId } const cloneRespBody = (await cloneResponse.json()) as { success: boolean; new_path: string }; + + const realAtt = Attachment.create({ + filename: attEnt.userFilename, + url: `${Config.get().cdn.endpointPublic}/${cloneRespBody.new_path}`, + proxy_url: `${Config.get().cdn.endpointPublic}/${cloneRespBody.new_path}`, + size: attEnt.size, + height: attEnt.height, + width: attEnt.width, + content_type: attEnt.contentType || attEnt.userOriginalContentType, + }); + await realAtt.save(); + //TODO maybe this needs to be a new DB object? I don't see a reason to do this rn though, though this id *should* technically be different from the id of the attachment - media.id = attEnt.id; + media.id = realAtt.id; media.proxy_url = `${Config.get().cdn.endpointPublic}/${cloneRespBody.new_path}`; if (url.protocol !== "attachment") media.url = media.proxy_url; media.height = attEnt.height;