trilium/src/routes/api/recent_changes.js

37 lines
1.1 KiB
JavaScript
Raw Normal View History

2017-10-22 09:10:33 +08:00
"use strict";
2017-10-16 07:47:05 +08:00
const sql = require('../../services/sql');
const protectedSessionService = require('../../services/protected_session');
async function getRecentChanges() {
const recentChanges = await sql.getRows(
2017-12-04 06:46:56 +08:00
`SELECT
2018-01-29 08:30:14 +08:00
notes.isDeleted AS current_isDeleted,
notes.title AS current_title,
notes.isProtected AS current_isProtected,
note_revisions.*
2017-12-04 06:46:56 +08:00
FROM
note_revisions
2018-01-29 08:30:14 +08:00
JOIN notes USING(noteId)
2017-12-04 06:46:56 +08:00
ORDER BY
2019-03-13 03:58:31 +08:00
utcDateModifiedTo DESC
2017-12-04 06:46:56 +08:00
LIMIT 1000`);
for (const change of recentChanges) {
if (change.current_isProtected) {
if (protectedSessionService.isProtectedSessionAvailable()) {
change.title = protectedSessionService.decryptNoteTitle(change.noteId, change.title);
change.current_title = protectedSessionService.decryptNoteTitle(change.noteId, change.current_title);
}
else {
change.title = change.current_title = "[Protected]";
}
}
}
return recentChanges;
}
module.exports = {
getRecentChanges
};