2017-10-21 21:10:33 -04:00
|
|
|
"use strict";
|
|
|
|
|
2017-10-15 19:47:05 -04:00
|
|
|
const sql = require('../../services/sql');
|
2018-11-06 17:47:40 +01:00
|
|
|
const protectedSessionService = require('../../services/protected_session');
|
2017-10-14 23:31:44 -04:00
|
|
|
|
2018-03-30 13:56:46 -04:00
|
|
|
async function getRecentChanges() {
|
2018-01-29 17:41:59 -05:00
|
|
|
const recentChanges = await sql.getRows(
|
2017-12-03 17:46:56 -05:00
|
|
|
`SELECT
|
2018-01-28 19:30:14 -05:00
|
|
|
notes.isDeleted AS current_isDeleted,
|
|
|
|
notes.title AS current_title,
|
2018-11-06 17:47:40 +01:00
|
|
|
notes.isProtected AS current_isProtected,
|
2018-01-28 19:38:05 -05:00
|
|
|
note_revisions.*
|
2017-12-03 17:46:56 -05:00
|
|
|
FROM
|
2018-01-28 19:38:05 -05:00
|
|
|
note_revisions
|
2018-01-28 19:30:14 -05:00
|
|
|
JOIN notes USING(noteId)
|
2017-12-03 17:46:56 -05:00
|
|
|
ORDER BY
|
2018-01-28 19:30:14 -05:00
|
|
|
dateModifiedTo DESC
|
2017-12-03 17:46:56 -05:00
|
|
|
LIMIT 1000`);
|
2017-10-14 23:31:44 -04:00
|
|
|
|
2019-03-04 20:44:20 +01:00
|
|
|
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 {
|
2018-11-06 17:47:40 +01:00
|
|
|
change.title = change.current_title = "[Protected]";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-30 13:56:46 -04:00
|
|
|
return recentChanges;
|
|
|
|
}
|
2017-10-14 23:31:44 -04:00
|
|
|
|
2018-03-30 13:56:46 -04:00
|
|
|
module.exports = {
|
|
|
|
getRecentChanges
|
|
|
|
};
|