attachment preview, closes #210

This commit is contained in:
azivner
2018-11-16 18:40:58 +01:00
parent 94565e3ec0
commit 6b65592d7a
4 changed files with 30 additions and 2 deletions

View File

@@ -13,8 +13,17 @@ async function getNote(req) {
}
if (note.type === 'file' || note.type === 'image') {
// no need to transfer (potentially large) file/image payload for this request
note.content = null;
if (note.type === 'file' && note.mime.startsWith('text/')) {
note.content = note.content.toString("UTF-8");
if (note.content.length > 10000) {
note.content = note.content.substr(0, 10000) + "...";
}
}
else {
// no need to transfer (potentially large) file/image payload for this request
note.content = null;
}
}
return note;