Skip to content

Commit

Permalink
Use sendResult's status code
Browse files Browse the repository at this point in the history
  • Loading branch information
ledyba committed Nov 16, 2024
1 parent eef1236 commit 1439750
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions server/src/controller/both/EntityController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,12 @@ export default class EntityController {
.type('text/plain;charset=UTF-8')
.send(msg);
}
if (sendResult.statusCode !== 200) {
return reply
.code(sendResult.statusCode)
.type('text/plain;charset=UTF-8')
.send(`[BUG] Failed to make valid stream.`);
}
const stream = sendResult.stream;

switch (type) {
case 'original':
return reply
.code(200)
.code(sendResult.statusCode)
.type(entity.mimeType)
.header('content-disposition', `inline; filename=\"${id+".original"+ext}\"`)
.send(stream);
Expand All @@ -108,14 +102,14 @@ export default class EntityController {
.send('Failed to probe entity.');
}
return reply
.code(200)
.code(sendResult.statusCode)
.type(meta.mime)
.header('content-disposition', `inline; filename=\"${id+".medium"+ext}\"`)
.send(stream);
}
case 'icon':
return reply
.code(200)
.code(sendResult.statusCode)
.type('image/jpeg')
.header("content-disposition", `inline; filename=\"${id+".icon"+ext}\"`)
.send(stream);
Expand Down

0 comments on commit 1439750

Please sign in to comment.