|
|
|
|
@ -72,116 +72,6 @@ async function update(req) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function getNote(req) {
|
|
|
|
|
const noteId = req.params.noteId;
|
|
|
|
|
const entity = await sql.getRow("SELECT * FROM notes WHERE noteId = ?", [noteId]);
|
|
|
|
|
|
|
|
|
|
syncService.serializeNoteContentBuffer(entity);
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
entity: entity
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function getBranch(req) {
|
|
|
|
|
const branchId = req.params.branchId;
|
|
|
|
|
|
|
|
|
|
return await sql.getRow("SELECT * FROM branches WHERE branchId = ?", [branchId]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function getNoteRevision(req) {
|
|
|
|
|
const noteRevisionId = req.params.noteRevisionId;
|
|
|
|
|
|
|
|
|
|
return await sql.getRow("SELECT * FROM note_revisions WHERE noteRevisionId = ?", [noteRevisionId]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function getOption(req) {
|
|
|
|
|
const name = req.params.name;
|
|
|
|
|
const opt = await sql.getRow("SELECT * FROM options WHERE name = ?", [name]);
|
|
|
|
|
|
|
|
|
|
if (!opt.isSynced) {
|
|
|
|
|
return [400, "This option can't be synced."];
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return opt;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function getRecentNote(req) {
|
|
|
|
|
const branchId = req.params.branchId;
|
|
|
|
|
|
|
|
|
|
return await sql.getRow("SELECT * FROM recent_notes WHERE branchId = ?", [branchId]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function getImage(req) {
|
|
|
|
|
const imageId = req.params.imageId;
|
|
|
|
|
const entity = await sql.getRow("SELECT * FROM images WHERE imageId = ?", [imageId]);
|
|
|
|
|
|
|
|
|
|
if (entity && entity.data !== null) {
|
|
|
|
|
entity.data = entity.data.toString('base64');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return entity;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function getNoteImage(req) {
|
|
|
|
|
const noteImageId = req.params.noteImageId;
|
|
|
|
|
|
|
|
|
|
return await sql.getRow("SELECT * FROM note_images WHERE noteImageId = ?", [noteImageId]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function getLabel(req) {
|
|
|
|
|
const labelId = req.params.labelId;
|
|
|
|
|
|
|
|
|
|
return await sql.getRow("SELECT * FROM labels WHERE labelId = ?", [labelId]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function getApiToken(req) {
|
|
|
|
|
const apiTokenId = req.params.apiTokenId;
|
|
|
|
|
|
|
|
|
|
return await sql.getRow("SELECT * FROM api_tokens WHERE apiTokenId = ?", [apiTokenId]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function updateNote(req) {
|
|
|
|
|
await syncUpdateService.updateNote(req.body.entity, req.body.sourceId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function updateBranch(req) {
|
|
|
|
|
await syncUpdateService.updateBranch(req.body.entity, req.body.sourceId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function updateNoteRevision(req) {
|
|
|
|
|
await syncUpdateService.updateNoteRevision(req.body.entity, req.body.sourceId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function updateNoteReordering(req) {
|
|
|
|
|
await syncUpdateService.updateNoteReordering(req.body.entity, req.body.sourceId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function updateOption(req) {
|
|
|
|
|
await syncUpdateService.updateOptions(req.body.entity, req.body.sourceId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function updateRecentNote(req) {
|
|
|
|
|
await syncUpdateService.updateRecentNotes(req.body.entity, req.body.sourceId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function updateImage(req) {
|
|
|
|
|
await syncUpdateService.updateImage(req.body.entity, req.body.sourceId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function updateNoteImage(req) {
|
|
|
|
|
await syncUpdateService.updateNoteImage(req.body.entity, req.body.sourceId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function updateLabel(req) {
|
|
|
|
|
await syncUpdateService.updateLabel(req.body.entity, req.body.sourceId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function updateApiToken(req) {
|
|
|
|
|
await syncUpdateService.updateApiToken(req.body.entity, req.body.sourceId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
checkSync,
|
|
|
|
|
syncNow,
|
|
|
|
|
@ -189,24 +79,5 @@ module.exports = {
|
|
|
|
|
forceFullSync,
|
|
|
|
|
forceNoteSync,
|
|
|
|
|
getChanged,
|
|
|
|
|
getNote,
|
|
|
|
|
getBranch,
|
|
|
|
|
getImage,
|
|
|
|
|
getNoteImage,
|
|
|
|
|
getNoteRevision,
|
|
|
|
|
getRecentNote,
|
|
|
|
|
getOption,
|
|
|
|
|
getLabel,
|
|
|
|
|
getApiToken,
|
|
|
|
|
updateNote,
|
|
|
|
|
updateBranch,
|
|
|
|
|
updateImage,
|
|
|
|
|
updateNoteImage,
|
|
|
|
|
updateNoteReordering,
|
|
|
|
|
updateNoteRevision,
|
|
|
|
|
updateRecentNote,
|
|
|
|
|
updateOption,
|
|
|
|
|
updateLabel,
|
|
|
|
|
updateApiToken,
|
|
|
|
|
update
|
|
|
|
|
};
|