mirror of
https://github.com/zadam/trilium.git
synced 2025-11-16 18:25:51 +01:00
refactored backend to use new naming convention for modules
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
const sql = require('../../services/sql');
|
||||
const utils = require('../../services/utils');
|
||||
const sync_table = require('../../services/sync_table');
|
||||
const syncTable = require('../../services/sync_table');
|
||||
const log = require('../../services/log');
|
||||
const repository = require('../../services/repository');
|
||||
|
||||
@@ -30,13 +30,13 @@ async function cleanupSoftDeletedItems() {
|
||||
|
||||
await sql.execute("DELETE FROM recent_notes");
|
||||
|
||||
await sync_table.cleanupSyncRowsForMissingEntities("notes", "noteId");
|
||||
await sync_table.cleanupSyncRowsForMissingEntities("branches", "branchId");
|
||||
await sync_table.cleanupSyncRowsForMissingEntities("note_revisions", "noteRevisionId");
|
||||
await sync_table.cleanupSyncRowsForMissingEntities("recent_notes", "branchId");
|
||||
await sync_table.cleanupSyncRowsForMissingEntities("images", "imageId");
|
||||
await sync_table.cleanupSyncRowsForMissingEntities("note_images", "noteImageId");
|
||||
await sync_table.cleanupSyncRowsForMissingEntities("labels", "labelId");
|
||||
await syncTable.cleanupSyncRowsForMissingEntities("notes", "noteId");
|
||||
await syncTable.cleanupSyncRowsForMissingEntities("branches", "branchId");
|
||||
await syncTable.cleanupSyncRowsForMissingEntities("note_revisions", "noteRevisionId");
|
||||
await syncTable.cleanupSyncRowsForMissingEntities("recent_notes", "branchId");
|
||||
await syncTable.cleanupSyncRowsForMissingEntities("images", "imageId");
|
||||
await syncTable.cleanupSyncRowsForMissingEntities("note_images", "noteImageId");
|
||||
await syncTable.cleanupSyncRowsForMissingEntities("labels", "labelId");
|
||||
|
||||
log.info("Following notes has been completely cleaned from database: " + noteIdsSql);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
const sql = require('../../services/sql');
|
||||
const sync_table = require('../../services/sync_table');
|
||||
const syncTable = require('../../services/sync_table');
|
||||
const tree = require('../../services/tree');
|
||||
const Branch = require('../../entities/branch');
|
||||
|
||||
@@ -51,7 +51,7 @@ async function cloneNoteAfter(req) {
|
||||
await sql.execute("UPDATE branches SET notePosition = notePosition + 1 WHERE parentNoteId = ? AND notePosition > ? AND isDeleted = 0",
|
||||
[afterNote.parentNoteId, afterNote.notePosition]);
|
||||
|
||||
await sync_table.addNoteReorderingSync(afterNote.parentNoteId);
|
||||
await syncTable.addNoteReorderingSync(afterNote.parentNoteId);
|
||||
|
||||
const branch = new Branch({
|
||||
noteId: noteId,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
const notes = require('../../services/notes');
|
||||
const labels = require('../../services/labels');
|
||||
const protected_session = require('../../services/protected_session');
|
||||
const noteService = require('../../services/notes');
|
||||
const labelService = require('../../services/labels');
|
||||
const protectedSessionService = require('../../services/protected_session');
|
||||
const repository = require('../../services/repository');
|
||||
|
||||
async function uploadFile(req) {
|
||||
@@ -17,7 +17,7 @@ async function uploadFile(req) {
|
||||
return [404, `Note ${parentNoteId} doesn't exist.`];
|
||||
}
|
||||
|
||||
const {note} = await notes.createNewNote(parentNoteId, {
|
||||
const {note} = await noteService.createNewNote(parentNoteId, {
|
||||
title: originalName,
|
||||
content: file.buffer,
|
||||
target: 'into',
|
||||
@@ -26,8 +26,8 @@ async function uploadFile(req) {
|
||||
mime: file.mimetype
|
||||
});
|
||||
|
||||
await labels.createLabel(note.noteId, "original_file_name", originalName);
|
||||
await labels.createLabel(note.noteId, "file_size", size);
|
||||
await labelService.createLabel(note.noteId, "original_file_name", originalName);
|
||||
await labelService.createLabel(note.noteId, "file_size", size);
|
||||
|
||||
return {
|
||||
noteId: note.noteId
|
||||
@@ -42,7 +42,7 @@ async function downloadFile(req, res) {
|
||||
return res.status(404).send(`Note ${noteId} doesn't exist.`);
|
||||
}
|
||||
|
||||
if (note.isProtected && !protected_session.isProtectedSessionAvailable()) {
|
||||
if (note.isProtected && !protectedSessionService.isProtectedSessionAvailable()) {
|
||||
res.status(401).send("Protected session not available");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
const repository = require('../../services/repository');
|
||||
const labels = require('../../services/labels');
|
||||
const notes = require('../../services/notes');
|
||||
const labelService = require('../../services/labels');
|
||||
const noteService = require('../../services/notes');
|
||||
const tar = require('tar-stream');
|
||||
const stream = require('stream');
|
||||
const path = require('path');
|
||||
@@ -110,13 +110,13 @@ async function importNotes(files, parentNoteId) {
|
||||
file.data = file.data.toString("UTF-8");
|
||||
}
|
||||
|
||||
const noteId = await notes.createNote(parentNoteId, file.meta.title, file.data, {
|
||||
const noteId = await noteService.createNote(parentNoteId, file.meta.title, file.data, {
|
||||
type: file.meta.type,
|
||||
mime: file.meta.mime
|
||||
});
|
||||
|
||||
for (const label of file.meta.labels) {
|
||||
await labels.createLabel(noteId, label.name, label.value);
|
||||
await labelService.createLabel(noteId, label.name, label.value);
|
||||
}
|
||||
|
||||
if (file.children.length > 0) {
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
const sql = require('../../services/sql');
|
||||
const utils = require('../../services/utils');
|
||||
const labels = require('../../services/labels');
|
||||
const labelService = require('../../services/labels');
|
||||
const repository = require('../../services/repository');
|
||||
const Label = require('../../entities/label');
|
||||
|
||||
@@ -46,7 +45,7 @@ async function updateNoteLabels(req) {
|
||||
async function getAllLabelNames() {
|
||||
const names = await sql.getColumn("SELECT DISTINCT name FROM labels WHERE isDeleted = 0");
|
||||
|
||||
for (const label of labels.BUILTIN_LABELS) {
|
||||
for (const label of labelService.BUILTIN_LABELS) {
|
||||
if (!names.includes(label)) {
|
||||
names.push(label);
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
const options = require('../../services/options');
|
||||
const utils = require('../../services/utils');
|
||||
const source_id = require('../../services/source_id');
|
||||
const password_encryption = require('../../services/password_encryption');
|
||||
const protected_session = require('../../services/protected_session');
|
||||
const app_info = require('../../services/app_info');
|
||||
const sourceIdService = require('../../services/source_id');
|
||||
const passwordEncryptionService = require('../../services/password_encryption');
|
||||
const protectedSessionService = require('../../services/protected_session');
|
||||
const appInfo = require('../../services/app_info');
|
||||
|
||||
async function loginSync(req) {
|
||||
const timestampStr = req.body.timestamp;
|
||||
@@ -20,8 +20,8 @@ async function loginSync(req) {
|
||||
|
||||
const dbVersion = req.body.dbVersion;
|
||||
|
||||
if (dbVersion !== app_info.db_version) {
|
||||
return [400, { message: 'Non-matching db versions, local is version ' + app_info.db_version }];
|
||||
if (dbVersion !== appInfo.db_version) {
|
||||
return [400, { message: 'Non-matching db versions, local is version ' + appInfo.db_version }];
|
||||
}
|
||||
|
||||
const documentSecret = await options.getOption('document_secret');
|
||||
@@ -36,23 +36,23 @@ async function loginSync(req) {
|
||||
req.session.loggedIn = true;
|
||||
|
||||
return {
|
||||
sourceId: source_id.getCurrentSourceId()
|
||||
sourceId: sourceIdService.getCurrentSourceId()
|
||||
};
|
||||
}
|
||||
|
||||
async function loginToProtectedSession(req) {
|
||||
const password = req.body.password;
|
||||
|
||||
if (!await password_encryption.verifyPassword(password)) {
|
||||
if (!await passwordEncryptionService.verifyPassword(password)) {
|
||||
return {
|
||||
success: false,
|
||||
message: "Given current password doesn't match hash"
|
||||
};
|
||||
}
|
||||
|
||||
const decryptedDataKey = await password_encryption.getDataKey(password);
|
||||
const decryptedDataKey = await passwordEncryptionService.getDataKey(password);
|
||||
|
||||
const protectedSessionId = protected_session.setDataKey(req, decryptedDataKey);
|
||||
const protectedSessionId = protectedSessionService.setDataKey(req, decryptedDataKey);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
"use strict";
|
||||
|
||||
const options = require('../../services/options');
|
||||
const migration = require('../../services/migration');
|
||||
const app_info = require('../../services/app_info');
|
||||
const optionService = require('../../services/options');
|
||||
const migrationService = require('../../services/migration');
|
||||
const appInfo = require('../../services/app_info');
|
||||
|
||||
async function getMigrationInfo() {
|
||||
return {
|
||||
db_version: parseInt(await options.getOption('db_version')),
|
||||
app_db_version: app_info.db_version
|
||||
db_version: parseInt(await optionService.getOption('db_version')),
|
||||
app_db_version: appInfo.db_version
|
||||
};
|
||||
}
|
||||
|
||||
async function executeMigration() {
|
||||
const migrations = await migration.migrate();
|
||||
const migrations = await migrationService.migrate();
|
||||
|
||||
return {
|
||||
migrations: migrations
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
const notes = require('../../services/notes');
|
||||
const tree = require('../../services/tree');
|
||||
const noteService = require('../../services/notes');
|
||||
const treeService = require('../../services/tree');
|
||||
const repository = require('../../services/repository');
|
||||
|
||||
async function getNote(req) {
|
||||
@@ -24,7 +24,7 @@ async function createNote(req) {
|
||||
const parentNoteId = req.params.parentNoteId;
|
||||
const newNote = req.body;
|
||||
|
||||
const { note, branch } = await notes.createNewNote(parentNoteId, newNote, req);
|
||||
const { note, branch } = await noteService.createNewNote(parentNoteId, newNote, req);
|
||||
|
||||
return {
|
||||
note,
|
||||
@@ -36,13 +36,13 @@ async function updateNote(req) {
|
||||
const note = req.body;
|
||||
const noteId = req.params.noteId;
|
||||
|
||||
await notes.updateNote(noteId, note);
|
||||
await noteService.updateNote(noteId, note);
|
||||
}
|
||||
|
||||
async function sortNotes(req) {
|
||||
const noteId = req.params.noteId;
|
||||
|
||||
await tree.sortNotesAlphabetically(noteId);
|
||||
await treeService.sortNotesAlphabetically(noteId);
|
||||
}
|
||||
|
||||
async function protectBranch(req) {
|
||||
@@ -50,7 +50,7 @@ async function protectBranch(req) {
|
||||
const note = repository.getNote(noteId);
|
||||
const protect = !!parseInt(req.params.isProtected);
|
||||
|
||||
await notes.protectNoteRecursively(note, protect);
|
||||
await noteService.protectNoteRecursively(note, protect);
|
||||
}
|
||||
|
||||
async function setNoteTypeMime(req) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
const sql = require('../../services/sql');
|
||||
const options = require('../../services/options');
|
||||
const optionService = require('../../services/options');
|
||||
|
||||
// options allowed to be updated directly in options dialog
|
||||
const ALLOWED_OPTIONS = ['protected_session_timeout', 'note_revision_snapshot_time_interval'];
|
||||
@@ -20,7 +20,7 @@ async function updateOption(req) {
|
||||
return [400, "not allowed option to set"];
|
||||
}
|
||||
|
||||
await options.setOption(name, value);
|
||||
await optionService.setOption(name, value);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
const repository = require('../../services/repository');
|
||||
const utils = require('../../services/utils');
|
||||
const options = require('../../services/options');
|
||||
const optionService = require('../../services/options');
|
||||
const RecentNote = require('../../entities/recent_note');
|
||||
|
||||
async function getRecentNotes() {
|
||||
@@ -33,7 +33,7 @@ async function addRecentNote(req) {
|
||||
|
||||
await recentNote.save();
|
||||
|
||||
await options.setOption('start_note_path', notePath);
|
||||
await optionService.setOption('start_note_path', notePath);
|
||||
|
||||
return await getRecentNotes();
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
const labels = require('../../services/labels');
|
||||
const script = require('../../services/script');
|
||||
const labelService = require('../../services/labels');
|
||||
const scriptService = require('../../services/script');
|
||||
const repository = require('../../services/repository');
|
||||
|
||||
async function exec(req) {
|
||||
const result = await script.executeScript(req.body.script, req.body.params, req.body.startNoteId, req.body.currentNoteId);
|
||||
const result = await scriptService.executeScript(req.body.script, req.body.params, req.body.startNoteId, req.body.currentNoteId);
|
||||
|
||||
return { executionResult: result };
|
||||
}
|
||||
@@ -13,18 +13,18 @@ async function exec(req) {
|
||||
async function run(req) {
|
||||
const note = await repository.getNote(req.params.noteId);
|
||||
|
||||
const result = await script.executeNote(req, note);
|
||||
const result = await scriptService.executeNote(req, note);
|
||||
|
||||
return { executionResult: result };
|
||||
}
|
||||
|
||||
async function getStartupBundles(req) {
|
||||
const notes = await labels.getNotesWithLabel("run", "frontend_startup");
|
||||
const notes = await labelService.getNotesWithLabel("run", "frontend_startup");
|
||||
|
||||
const bundles = [];
|
||||
|
||||
for (const note of notes) {
|
||||
const bundle = await script.getScriptBundle(note);
|
||||
const bundle = await scriptService.getScriptBundle(note);
|
||||
|
||||
if (bundle) {
|
||||
bundles.push(bundle);
|
||||
@@ -36,7 +36,7 @@ async function getStartupBundles(req) {
|
||||
|
||||
async function getBundle(req) {
|
||||
const note = await repository.getNote(req.params.noteId);
|
||||
return await script.getScriptBundle(note);
|
||||
return await scriptService.getScriptBundle(note);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
const sql = require('../../services/sql');
|
||||
const notes = require('../../services/notes');
|
||||
const noteService = require('../../services/notes');
|
||||
const parseFilters = require('../../services/parse_filters');
|
||||
const buildSearchQuery = require('../../services/build_search_query');
|
||||
|
||||
@@ -20,7 +20,7 @@ async function saveSearchToNote(req) {
|
||||
searchString: req.params.searchString
|
||||
};
|
||||
|
||||
const noteId = await notes.createNote('root', 'Search note', noteContent, {
|
||||
const noteId = await noteService.createNote('root', 'Search note', noteContent, {
|
||||
json: true,
|
||||
type: 'search',
|
||||
mime: "application/json"
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
"use strict";
|
||||
|
||||
const image = require('../../services/image');
|
||||
const imageService = require('../../services/image');
|
||||
const utils = require('../../services/utils');
|
||||
const date_notes = require('../../services/date_notes');
|
||||
const dateNoteService = require('../../services/date_notes');
|
||||
const sql = require('../../services/sql');
|
||||
const notes = require('../../services/notes');
|
||||
const password_encryption = require('../../services/password_encryption');
|
||||
const options = require('../../services/options');
|
||||
const noteService = require('../../services/notes');
|
||||
const passwordEncryptionService = require('../../services/password_encryption');
|
||||
const optionService = require('../../services/options');
|
||||
const ApiToken = require('../../entities/api_token');
|
||||
|
||||
async function login(req) {
|
||||
const username = req.body.username;
|
||||
const password = req.body.password;
|
||||
|
||||
const isUsernameValid = username === await options.getOption('username');
|
||||
const isPasswordValid = await password_encryption.verifyPassword(password);
|
||||
const isUsernameValid = username === await optionService.getOption('username');
|
||||
const isPasswordValid = await passwordEncryptionService.verifyPassword(password);
|
||||
|
||||
if (!isUsernameValid || !isPasswordValid) {
|
||||
return [401, "Incorrect username/password"];
|
||||
@@ -35,9 +35,9 @@ async function uploadImage(req) {
|
||||
return [400, "Unknown image type: " + file.mimetype];
|
||||
}
|
||||
|
||||
const parentNoteId = await date_notes.getDateNoteId(req.headers['x-local-date']);
|
||||
const parentNoteId = await dateNoteService.getDateNoteId(req.headers['x-local-date']);
|
||||
|
||||
const {note} = await notes.createNewNote(parentNoteId, {
|
||||
const {note} = await noteService.createNewNote(parentNoteId, {
|
||||
title: "Sender image",
|
||||
content: "",
|
||||
target: 'into',
|
||||
@@ -46,7 +46,7 @@ async function uploadImage(req) {
|
||||
mime: 'text/html'
|
||||
});
|
||||
|
||||
const {fileName, imageId} = await image.saveImage(file, null, note.noteId);
|
||||
const {fileName, imageId} = await imageService.saveImage(file, null, note.noteId);
|
||||
|
||||
const url = `/api/images/${imageId}/${fileName}`;
|
||||
|
||||
@@ -56,9 +56,9 @@ async function uploadImage(req) {
|
||||
}
|
||||
|
||||
async function saveNote(req) {
|
||||
const parentNoteId = await date_notes.getDateNoteId(req.headers['x-local-date']);
|
||||
const parentNoteId = await dateNoteService.getDateNoteId(req.headers['x-local-date']);
|
||||
|
||||
await notes.createNewNote(parentNoteId, {
|
||||
await noteService.createNewNote(parentNoteId, {
|
||||
title: req.body.title,
|
||||
content: req.body.content,
|
||||
target: 'into',
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
"use strict";
|
||||
|
||||
const options = require('../../services/options');
|
||||
const optionService = require('../../services/options');
|
||||
const sql = require('../../services/sql');
|
||||
const utils = require('../../services/utils');
|
||||
const my_scrypt = require('../../services/my_scrypt');
|
||||
const password_encryption = require('../../services/password_encryption');
|
||||
const myScryptService = require('../../services/my_scrypt');
|
||||
const passwordEncryptionService = require('../../services/password_encryption');
|
||||
|
||||
async function setup(req) {
|
||||
const { username, password } = req.body;
|
||||
|
||||
await options.setOption('username', username);
|
||||
await optionService.setOption('username', username);
|
||||
|
||||
await options.setOption('password_verification_salt', utils.randomSecureToken(32));
|
||||
await options.setOption('password_derived_key_salt', utils.randomSecureToken(32));
|
||||
await optionService.setOption('password_verification_salt', utils.randomSecureToken(32));
|
||||
await optionService.setOption('password_derived_key_salt', utils.randomSecureToken(32));
|
||||
|
||||
const passwordVerificationKey = utils.toBase64(await my_scrypt.getVerificationHash(password));
|
||||
await options.setOption('password_verification_hash', passwordVerificationKey);
|
||||
const passwordVerificationKey = utils.toBase64(await myScryptService.getVerificationHash(password));
|
||||
await optionService.setOption('password_verification_hash', passwordVerificationKey);
|
||||
|
||||
await password_encryption.setDataKey(password, utils.randomSecureToken(16));
|
||||
await passwordEncryptionService.setDataKey(password, utils.randomSecureToken(16));
|
||||
|
||||
sql.setDbReadyAsResolved();
|
||||
}
|
||||
|
||||
@@ -1,58 +1,58 @@
|
||||
"use strict";
|
||||
|
||||
const sync = require('../../services/sync');
|
||||
const syncUpdate = require('../../services/sync_update');
|
||||
const sync_table = require('../../services/sync_table');
|
||||
const syncService = require('../../services/sync');
|
||||
const syncUpdateService = require('../../services/sync_update');
|
||||
const syncTableService = require('../../services/sync_table');
|
||||
const sql = require('../../services/sql');
|
||||
const options = require('../../services/options');
|
||||
const content_hash = require('../../services/content_hash');
|
||||
const optionService = require('../../services/options');
|
||||
const contentHashService = require('../../services/content_hash');
|
||||
const log = require('../../services/log');
|
||||
|
||||
async function checkSync() {
|
||||
return {
|
||||
'hashes': await content_hash.getHashes(),
|
||||
'hashes': await contentHashService.getHashes(),
|
||||
'max_sync_id': await sql.getValue('SELECT MAX(id) FROM sync')
|
||||
};
|
||||
}
|
||||
|
||||
async function syncNow() {
|
||||
return await sync.sync();
|
||||
return await syncService.sync();
|
||||
}
|
||||
|
||||
async function fillSyncRows() {
|
||||
await sync_table.fillAllSyncRows();
|
||||
await syncTableService.fillAllSyncRows();
|
||||
|
||||
log.info("Sync rows have been filled.");
|
||||
}
|
||||
|
||||
async function forceFullSync() {
|
||||
await options.setOption('last_synced_pull', 0);
|
||||
await options.setOption('last_synced_push', 0);
|
||||
await optionService.setOption('last_synced_pull', 0);
|
||||
await optionService.setOption('last_synced_push', 0);
|
||||
|
||||
log.info("Forcing full sync.");
|
||||
|
||||
// not awaiting for the job to finish (will probably take a long time)
|
||||
sync.sync();
|
||||
syncService.sync();
|
||||
}
|
||||
|
||||
async function forceNoteSync(req) {
|
||||
const noteId = req.params.noteId;
|
||||
|
||||
await sync_table.addNoteSync(noteId);
|
||||
await syncTableService.addNoteSync(noteId);
|
||||
|
||||
for (const branchId of await sql.getColumn("SELECT branchId FROM branches WHERE isDeleted = 0 AND noteId = ?", [noteId])) {
|
||||
await sync_table.addBranchSync(branchId);
|
||||
await sync_table.addRecentNoteSync(branchId);
|
||||
await syncTableService.addBranchSync(branchId);
|
||||
await syncTableService.addRecentNoteSync(branchId);
|
||||
}
|
||||
|
||||
for (const noteRevisionId of await sql.getColumn("SELECT noteRevisionId FROM note_revisions WHERE noteId = ?", [noteId])) {
|
||||
await sync_table.addNoteRevisionSync(noteRevisionId);
|
||||
await syncTableService.addNoteRevisionSync(noteRevisionId);
|
||||
}
|
||||
|
||||
log.info("Forcing note sync for " + noteId);
|
||||
|
||||
// not awaiting for the job to finish (will probably take a long time)
|
||||
sync.sync();
|
||||
syncService.sync();
|
||||
}
|
||||
|
||||
async function getChanged() {
|
||||
@@ -65,7 +65,7 @@ async function getNote(req) {
|
||||
const noteId = req.params.noteId;
|
||||
const entity = await sql.getRow("SELECT * FROM notes WHERE noteId = ?", [noteId]);
|
||||
|
||||
sync.serializeNoteContentBuffer(entity);
|
||||
syncService.serializeNoteContentBuffer(entity);
|
||||
|
||||
return {
|
||||
entity: entity
|
||||
@@ -141,43 +141,43 @@ async function getApiToken(req) {
|
||||
}
|
||||
|
||||
async function updateNote(req) {
|
||||
await syncUpdate.updateNote(req.body.entity, req.body.sourceId);
|
||||
await syncUpdateService.updateNote(req.body.entity, req.body.sourceId);
|
||||
}
|
||||
|
||||
async function updateBranch(req) {
|
||||
await syncUpdate.updateBranch(req.body.entity, req.body.sourceId);
|
||||
await syncUpdateService.updateBranch(req.body.entity, req.body.sourceId);
|
||||
}
|
||||
|
||||
async function updateNoteRevision(req) {
|
||||
await syncUpdate.updateNoteRevision(req.body.entity, req.body.sourceId);
|
||||
await syncUpdateService.updateNoteRevision(req.body.entity, req.body.sourceId);
|
||||
}
|
||||
|
||||
async function updateNoteReordering(req) {
|
||||
await syncUpdate.updateNoteReordering(req.body.entity, req.body.sourceId);
|
||||
await syncUpdateService.updateNoteReordering(req.body.entity, req.body.sourceId);
|
||||
}
|
||||
|
||||
async function updateOption(req) {
|
||||
await syncUpdate.updateOptions(req.body.entity, req.body.sourceId);
|
||||
await syncUpdateService.updateOptions(req.body.entity, req.body.sourceId);
|
||||
}
|
||||
|
||||
async function updateRecentNote(req) {
|
||||
await syncUpdate.updateRecentNotes(req.body.entity, req.body.sourceId);
|
||||
await syncUpdateService.updateRecentNotes(req.body.entity, req.body.sourceId);
|
||||
}
|
||||
|
||||
async function updateImage(req) {
|
||||
await syncUpdate.updateImage(req.body.entity, req.body.sourceId);
|
||||
await syncUpdateService.updateImage(req.body.entity, req.body.sourceId);
|
||||
}
|
||||
|
||||
async function updateNoteImage(req) {
|
||||
await syncUpdate.updateNoteImage(req.body.entity, req.body.sourceId);
|
||||
await syncUpdateService.updateNoteImage(req.body.entity, req.body.sourceId);
|
||||
}
|
||||
|
||||
async function updateLabel(req) {
|
||||
await syncUpdate.updateLabel(req.body.entity, req.body.sourceId);
|
||||
await syncUpdateService.updateLabel(req.body.entity, req.body.sourceId);
|
||||
}
|
||||
|
||||
async function updateApiToken(req) {
|
||||
await syncUpdate.updateApiToken(req.body.entity, req.body.sourceId);
|
||||
await syncUpdateService.updateApiToken(req.body.entity, req.body.sourceId);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
"use strict";
|
||||
|
||||
const sql = require('../../services/sql');
|
||||
const options = require('../../services/options');
|
||||
const utils = require('../../services/utils');
|
||||
const optionService = require('../../services/options');
|
||||
const config = require('../../services/config');
|
||||
const protected_session = require('../../services/protected_session');
|
||||
const repository = require('../../services/repository');
|
||||
const protectedSessionService = require('../../services/protected_session');
|
||||
|
||||
async function getTree() {
|
||||
const branches = await sql.getRows(`
|
||||
@@ -45,7 +43,7 @@ async function getTree() {
|
||||
WHERE
|
||||
notes.isDeleted = 0`));
|
||||
|
||||
protected_session.decryptNotes(notes);
|
||||
protectedSessionService.decryptNotes(notes);
|
||||
|
||||
notes.forEach(note => {
|
||||
note.hideInAutocomplete = !!note.hideInAutocomplete;
|
||||
@@ -56,7 +54,7 @@ async function getTree() {
|
||||
instanceName: config.General ? config.General.instanceName : null,
|
||||
branches: branches,
|
||||
notes: notes,
|
||||
start_note_path: await options.getOption('start_note_path')
|
||||
start_note_path: await optionService.getOption('start_note_path')
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user