mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
sync cleanup
This commit is contained in:
parent
13f71f8967
commit
36b15f474d
@ -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
|
||||
};
|
@ -148,26 +148,6 @@ function register(app) {
|
||||
apiRoute(POST, '/api/sync/force-note-sync/:noteId', syncApiRoute.forceNoteSync);
|
||||
apiRoute(GET, '/api/sync/changed', syncApiRoute.getChanged);
|
||||
apiRoute(PUT, '/api/sync/update', syncApiRoute.update);
|
||||
apiRoute(GET, '/api/sync/notes/:noteId', syncApiRoute.getNote);
|
||||
apiRoute(GET, '/api/sync/branches/:branchId', syncApiRoute.getBranch);
|
||||
apiRoute(GET, '/api/sync/note_revisions/:noteRevisionId', syncApiRoute.getNoteRevision);
|
||||
apiRoute(GET, '/api/sync/options/:name', syncApiRoute.getOption);
|
||||
apiRoute(GET, '/api/sync/note_reordering/:parentNoteId', syncApiRoute.getNoteReordering);
|
||||
apiRoute(GET, '/api/sync/recent_notes/:branchId', syncApiRoute.getRecentNote);
|
||||
apiRoute(GET, '/api/sync/images/:imageId', syncApiRoute.getImage);
|
||||
apiRoute(GET, '/api/sync/note_images/:noteImageId', syncApiRoute.getNoteImage);
|
||||
apiRoute(GET, '/api/sync/labels/:labelId', syncApiRoute.getLabel);
|
||||
apiRoute(GET, '/api/sync/api_tokens/:apiTokenId', syncApiRoute.getApiToken);
|
||||
apiRoute(PUT, '/api/sync/notes', syncApiRoute.updateNote);
|
||||
apiRoute(PUT, '/api/sync/branches', syncApiRoute.updateBranch);
|
||||
apiRoute(PUT, '/api/sync/note_revisions', syncApiRoute.updateNoteRevision);
|
||||
apiRoute(PUT, '/api/sync/note_reordering', syncApiRoute.updateNoteReordering);
|
||||
apiRoute(PUT, '/api/sync/options', syncApiRoute.updateOption);
|
||||
apiRoute(PUT, '/api/sync/recent_notes', syncApiRoute.updateRecentNote);
|
||||
apiRoute(PUT, '/api/sync/images', syncApiRoute.updateImage);
|
||||
apiRoute(PUT, '/api/sync/note_images', syncApiRoute.updateNoteImage);
|
||||
apiRoute(PUT, '/api/sync/labels', syncApiRoute.updateLabel);
|
||||
apiRoute(PUT, '/api/sync/api_tokens', syncApiRoute.updateApiToken);
|
||||
|
||||
apiRoute(GET, '/api/event-log', eventLogRoute.getEventLog);
|
||||
|
||||
|
@ -195,15 +195,5 @@ async function updateApiToken(entity, sourceId) {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
updateEntity,
|
||||
updateNote,
|
||||
updateBranch,
|
||||
updateNoteRevision,
|
||||
updateNoteReordering,
|
||||
updateOptions,
|
||||
updateRecentNotes,
|
||||
updateImage,
|
||||
updateNoteImage,
|
||||
updateLabel,
|
||||
updateApiToken
|
||||
updateEntity
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user