From 36b15f474da8c2941a0bead885aa28522cafa93b Mon Sep 17 00:00:00 2001 From: azivner Date: Sat, 7 Apr 2018 22:32:46 -0400 Subject: [PATCH] sync cleanup --- src/routes/api/sync.js | 129 ------------------------------------ src/routes/routes.js | 20 ------ src/services/sync_update.js | 12 +--- 3 files changed, 1 insertion(+), 160 deletions(-) diff --git a/src/routes/api/sync.js b/src/routes/api/sync.js index d67b4f5a0..725626b9f 100644 --- a/src/routes/api/sync.js +++ b/src/routes/api/sync.js @@ -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 }; \ No newline at end of file diff --git a/src/routes/routes.js b/src/routes/routes.js index 83e58bed1..db956aab7 100644 --- a/src/routes/routes.js +++ b/src/routes/routes.js @@ -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); diff --git a/src/services/sync_update.js b/src/services/sync_update.js index 2858561a5..46cac889a 100644 --- a/src/services/sync_update.js +++ b/src/services/sync_update.js @@ -195,15 +195,5 @@ async function updateApiToken(entity, sourceId) { } module.exports = { - updateEntity, - updateNote, - updateBranch, - updateNoteRevision, - updateNoteReordering, - updateOptions, - updateRecentNotes, - updateImage, - updateNoteImage, - updateLabel, - updateApiToken + updateEntity }; \ No newline at end of file