chore: make lint happy

This commit is contained in:
CrescentLeaf
2025-10-01 00:57:34 +08:00
parent aa0d0e86a5
commit beab35a25e

View File

@@ -23,28 +23,27 @@ app.get('/uploaded_files/:hash', (req, res) => {
const hash = req.params.hash as string const hash = req.params.hash as string
res.setHeader('Content-Type', 'text/plain') res.setHeader('Content-Type', 'text/plain')
if (hash == null) { if (hash == null) {
res.send("404 Not Found", 404) res.status(404).send("404 Not Found")
return return
} }
const file = FileManager.findByHash(hash) const file = FileManager.findByHash(hash)
if (file == null) {
res.status(404).send("404 Not Found")
return
}
if (file.getChatId() != null) { if (file.getChatId() != null) {
const userToken = TokenManager.decode(req.cookies.token) const userToken = TokenManager.decode(req.cookies.token)
console.log(userToken, req.cookies.device_id)
if (!TokenManager.checkToken(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 return
} }
if (!UserChatLinker.checkUserIsLinkedToChat(userToken.author, file.getChatId())) { if (!UserChatLinker.checkUserIsLinkedToChat(userToken.author, file.getChatId() as string)) {
res.send("403 Forbidden", 403) res.status(403).send("403 Forbidden")
return return
} }
} }
if (file == null) {
res.send("404 Not Found", 404)
return
}
res.setHeader('Content-Type', file!.getMime()) res.setHeader('Content-Type', file!.getMime())
res.sendFile(path.resolve(file!.getFilePath())) res.sendFile(path.resolve(file!.getFilePath()))