support for loading and saving type and mime

This commit is contained in:
azivner
2018-01-21 23:36:09 -05:00
parent f9631ff59f
commit e56fb6d2d4
8 changed files with 40 additions and 20 deletions

View File

@@ -77,8 +77,7 @@ async function importNotes(dir, parentNoteId) {
note_position: notePos,
is_expanded: 0,
is_deleted: 0,
date_modified: now,
type: 'text'
date_modified: now
});
await sync_table.addNoteTreeSync(noteTreeId);
@@ -89,6 +88,8 @@ async function importNotes(dir, parentNoteId) {
note_text: noteText,
is_deleted: 0,
is_protected: 0,
type: 'text',
mime: 'text/html',
date_created: now,
date_modified: now
});

View File

@@ -93,14 +93,15 @@ router.put('/:noteId/protect-sub-tree/:isProtected', auth.checkApiAuth, wrap(asy
res.send({});
}));
router.put('/:noteId/type/:type', auth.checkApiAuth, wrap(async (req, res, next) => {
router.put('/:noteId/type/:type/mime/:mime', auth.checkApiAuth, wrap(async (req, res, next) => {
const noteId = req.params.noteId;
const type = req.params.type;
const mime = req.params.mime;
const sourceId = req.headers.source_id;
await sql.doInTransaction(async () => {
await sql.execute("UPDATE notes SET type = ?, date_modified = ? WHERE note_id = ?",
[type, utils.nowDate(), noteId]);
await sql.execute("UPDATE notes SET type = ?, mime = ?, date_modified = ? WHERE note_id = ?",
[type, mime, utils.nowDate(), noteId]);
await sync_table.addNoteSync(noteId, sourceId);
});