better error message in image attachment + upgrades

This commit is contained in:
zadam
2023-09-14 00:18:56 +02:00
parent d9666210f1
commit 4a67f63abd
3 changed files with 28 additions and 25 deletions

View File

@@ -55,7 +55,9 @@ function returnAttachedImage(req, res) {
}
if (!["image"].includes(attachment.role)) {
return res.sendStatus(400);
return res.setHeader("Content-Type", "text/plain")
.status(400)
.send(`Attachment '${attachment.attachmentId}' has role '${attachment.role}', but 'image' was expected.`);
}
res.set('Content-Type', attachment.mime);