diff options
author | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-09-25 23:54:52 +0200 |
---|---|---|
committer | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-09-25 23:54:52 +0200 |
commit | 1c49d8240065f8b3d4f134015d96e4fbd54cb2ee (patch) | |
tree | dd252d643ef35857d4db1eb4515415e15445d66f | |
parent | :lock: XSS content type: html (diff) | |
download | server-1c49d8240065f8b3d4f134015d96e4fbd54cb2ee.tar.xz |
:bug: message attachment url
-rw-r--r-- | api/src/routes/channels/#channel_id/messages/index.ts | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/api/src/routes/channels/#channel_id/messages/index.ts b/api/src/routes/channels/#channel_id/messages/index.ts index fab20977..d3321fae 100644 --- a/api/src/routes/channels/#channel_id/messages/index.ts +++ b/api/src/routes/channels/#channel_id/messages/index.ts @@ -3,6 +3,7 @@ import { Attachment, Channel, ChannelType, + Config, DmChannelDTO, Embed, emitEvent, @@ -15,6 +16,7 @@ import { HTTPError } from "lambert-server"; import { handleMessage, postHandleMessage, route } from "@fosscord/api"; import multer from "multer"; import { FindManyOptions, LessThan, MoreThan } from "typeorm"; +import { URL } from "url"; const router: Router = Router(); @@ -111,6 +113,9 @@ router.get("/", async (req: Request, res: Response) => { }); // @ts-ignore if (!x.author) x.author = { discriminator: "0000", username: "Deleted User", public_flags: "0", avatar: null }; + x.attachments?.forEach((x) => { + x.proxy_url = `${Config.get().cdn.endpointPublic || "http://localhost:3003"}${new URL(x.proxy_url).pathname}`; + }); return x; }) |