From df4f6578f76ae316064fd6074147710044609e22 Mon Sep 17 00:00:00 2001 From: Paul Makles Date: Sun, 27 Oct 2024 21:59:16 +0000 Subject: [PATCH] feat: add session token to file uploads --- src/controllers/client/jsx/legacy/FileUploads.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/controllers/client/jsx/legacy/FileUploads.tsx b/src/controllers/client/jsx/legacy/FileUploads.tsx index ec36bb6f..e2a44322 100644 --- a/src/controllers/client/jsx/legacy/FileUploads.tsx +++ b/src/controllers/client/jsx/legacy/FileUploads.tsx @@ -12,7 +12,7 @@ import { IconButton, Preloader } from "@revoltchat/ui"; import { determineFileSize } from "../../../../lib/fileSize"; import { modalController } from "../../../modals/ModalController"; -import { useClient } from "../../ClientController"; +import { clientController, useClient } from "../../ClientController"; import { takeError } from "../error"; type BehaviourType = @@ -67,9 +67,16 @@ export async function uploadFile( const formData = new FormData(); formData.append("file", file); + const client = clientController.getActiveSession()?.client; + const sesToken = + typeof client?.session === "string" + ? client.session + : client?.session?.token; + const res = await Axios.post(`${autumnURL}/${tag}`, formData, { headers: { "Content-Type": "multipart/form-data", + "X-Session-Token": sesToken, }, ...config, });