From beab35a25e345e11a37b1486ba7b30eb324b7c05 Mon Sep 17 00:00:00 2001 From: CrescentLeaf Date: Wed, 1 Oct 2025 00:57:34 +0800 Subject: [PATCH] chore: make lint happy --- server/main.ts | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/server/main.ts b/server/main.ts index b67775c..66ceddf 100644 --- a/server/main.ts +++ b/server/main.ts @@ -23,28 +23,27 @@ app.get('/uploaded_files/:hash', (req, res) => { const hash = req.params.hash as string res.setHeader('Content-Type', 'text/plain') if (hash == null) { - res.send("404 Not Found", 404) + res.status(404).send("404 Not Found") return } const file = FileManager.findByHash(hash) - + + if (file == null) { + res.status(404).send("404 Not Found") + return + } + if (file.getChatId() != null) { const userToken = TokenManager.decode(req.cookies.token) - console.log(userToken, req.cookies.device_id) if (!TokenManager.checkToken(userToken, req.cookies.device_id)) { - res.send("401 UnAuthorized", 401) + res.status(401).send("401 UnAuthorized") return } - if (!UserChatLinker.checkUserIsLinkedToChat(userToken.author, file.getChatId())) { - res.send("403 Forbidden", 403) + if (!UserChatLinker.checkUserIsLinkedToChat(userToken.author, file.getChatId() as string)) { + res.status(403).send("403 Forbidden") return } } - - if (file == null) { - res.send("404 Not Found", 404) - return - } res.setHeader('Content-Type', file!.getMime()) res.sendFile(path.resolve(file!.getFilePath()))