mirror of
https://github.com/zadam/trilium.git
synced 2025-11-03 11:56:01 +01:00
converted export/import notes
This commit is contained in:
@@ -1,38 +1,9 @@
|
||||
"use strict";
|
||||
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const sql = require('../../services/sql');
|
||||
const auth = require('../../services/auth');
|
||||
const utils = require('../../services/utils');
|
||||
const sync_table = require('../../services/sync_table');
|
||||
const options = require('../../services/options');
|
||||
const wrap = require('express-promise-wrap').wrap;
|
||||
|
||||
router.get('', auth.checkApiAuth, wrap(async (req, res, next) => {
|
||||
res.send(await getRecentNotes());
|
||||
}));
|
||||
|
||||
router.put('/:branchId/:notePath', auth.checkApiAuth, wrap(async (req, res, next) => {
|
||||
const branchId = req.params.branchId;
|
||||
const notePath = req.params.notePath;
|
||||
const sourceId = req.headers.source_id;
|
||||
|
||||
await sql.doInTransaction(async () => {
|
||||
await sql.replace('recent_notes', {
|
||||
branchId: branchId,
|
||||
notePath: notePath,
|
||||
dateAccessed: utils.nowDate(),
|
||||
isDeleted: 0
|
||||
});
|
||||
|
||||
await sync_table.addRecentNoteSync(branchId, sourceId);
|
||||
|
||||
await options.setOption('start_note_path', notePath, sourceId);
|
||||
});
|
||||
|
||||
res.send(await getRecentNotes());
|
||||
}));
|
||||
|
||||
async function getRecentNotes() {
|
||||
return await sql.getRows(`
|
||||
@@ -49,4 +20,27 @@ async function getRecentNotes() {
|
||||
LIMIT 200`);
|
||||
}
|
||||
|
||||
module.exports = router;
|
||||
|
||||
async function addRecentNote(req) {
|
||||
const branchId = req.params.branchId;
|
||||
const notePath = req.params.notePath;
|
||||
const sourceId = req.headers.source_id;
|
||||
|
||||
await sql.replace('recent_notes', {
|
||||
branchId: branchId,
|
||||
notePath: notePath,
|
||||
dateAccessed: utils.nowDate(),
|
||||
isDeleted: 0
|
||||
});
|
||||
|
||||
await sync_table.addRecentNoteSync(branchId, sourceId);
|
||||
|
||||
await options.setOption('start_note_path', notePath, sourceId);
|
||||
|
||||
return await getRecentNotes();
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getRecentNotes,
|
||||
addRecentNote
|
||||
};
|
||||
Reference in New Issue
Block a user