mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
server-ts: Convert routes/api/recent_changes
This commit is contained in:
parent
4b1c351195
commit
66d7548046
@ -1,16 +1,30 @@
|
||||
"use strict";
|
||||
|
||||
const sql = require('../../services/sql');
|
||||
const protectedSessionService = require('../../services/protected_session');
|
||||
const noteService = require('../../services/notes');
|
||||
const becca = require('../../becca/becca');
|
||||
import sql = require('../../services/sql');
|
||||
import protectedSessionService = require('../../services/protected_session');
|
||||
import noteService = require('../../services/notes');
|
||||
import becca = require('../../becca/becca');
|
||||
import { Request } from 'express';
|
||||
import { RevisionRow } from '../../becca/entities/rows';
|
||||
|
||||
function getRecentChanges(req) {
|
||||
interface RecentChangeRow {
|
||||
noteId: string;
|
||||
current_isDeleted: boolean;
|
||||
current_deleteId: string;
|
||||
current_title: string;
|
||||
current_isProtected: boolean,
|
||||
title: string;
|
||||
utcDate: string;
|
||||
date: string;
|
||||
canBeUndeleted?: boolean;
|
||||
}
|
||||
|
||||
function getRecentChanges(req: Request) {
|
||||
const {ancestorNoteId} = req.params;
|
||||
|
||||
let recentChanges = [];
|
||||
|
||||
const revisionRows = sql.getRows(`
|
||||
const revisionRows = sql.getRows<RecentChangeRow>(`
|
||||
SELECT
|
||||
notes.noteId,
|
||||
notes.isDeleted AS current_isDeleted,
|
||||
@ -36,7 +50,7 @@ function getRecentChanges(req) {
|
||||
// now we need to also collect date points not represented in note revisions:
|
||||
// 1. creation for all notes (dateCreated)
|
||||
// 2. deletion for deleted notes (dateModified)
|
||||
const noteRows = sql.getRows(`
|
||||
const noteRows = sql.getRows<RecentChangeRow>(`
|
||||
SELECT
|
||||
notes.noteId,
|
||||
notes.isDeleted AS current_isDeleted,
|
||||
@ -76,8 +90,8 @@ function getRecentChanges(req) {
|
||||
for (const change of recentChanges) {
|
||||
if (change.current_isProtected) {
|
||||
if (protectedSessionService.isProtectedSessionAvailable()) {
|
||||
change.title = protectedSessionService.decryptString(change.title);
|
||||
change.current_title = protectedSessionService.decryptString(change.current_title);
|
||||
change.title = protectedSessionService.decryptString(change.title) || "[protected]";
|
||||
change.current_title = protectedSessionService.decryptString(change.current_title) || "[protected]";
|
||||
}
|
||||
else {
|
||||
change.title = change.current_title = "[protected]";
|
||||
@ -97,6 +111,6 @@ function getRecentChanges(req) {
|
||||
return recentChanges;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export = {
|
||||
getRecentChanges
|
||||
};
|
@ -29,7 +29,7 @@ const attachmentsApiRoute = require('./api/attachments');
|
||||
const autocompleteApiRoute = require('./api/autocomplete');
|
||||
const cloningApiRoute = require('./api/cloning');
|
||||
const revisionsApiRoute = require('./api/revisions');
|
||||
const recentChangesApiRoute = require('./api/recent_changes.js');
|
||||
const recentChangesApiRoute = require('./api/recent_changes');
|
||||
const optionsApiRoute = require('./api/options');
|
||||
const passwordApiRoute = require('./api/password');
|
||||
const syncApiRoute = require('./api/sync');
|
||||
|
Loading…
x
Reference in New Issue
Block a user