mirror of
https://github.com/zadam/trilium.git
synced 2024-11-17 21:21:40 +08:00
24 lines
558 B
JavaScript
24 lines
558 B
JavaScript
|
"use strict";
|
||
|
|
||
|
const noteCacheService = require('../../services/note_cache');
|
||
|
const repository = require('../../services/repository');
|
||
|
|
||
|
async function getSimilarNotes(req) {
|
||
|
const noteId = req.params.noteId;
|
||
|
|
||
|
const note = await repository.getNote(noteId);
|
||
|
|
||
|
if (!note) {
|
||
|
return [404, `Note ${noteId} not found.`];
|
||
|
}
|
||
|
|
||
|
const results = await noteCacheService.findNotes(note.title);
|
||
|
|
||
|
return results
|
||
|
.map(r => r.noteId)
|
||
|
.filter(similarNoteId => similarNoteId !== noteId);
|
||
|
}
|
||
|
|
||
|
module.exports = {
|
||
|
getSimilarNotes
|
||
|
};
|