mirror of
https://github.com/zadam/trilium.git
synced 2024-11-17 13:14:44 +08:00
23 lines
No EOL
526 B
JavaScript
23 lines
No EOL
526 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.findSimilarNotes(note.title);
|
|
|
|
return results
|
|
.filter(note => note.noteId !== noteId);
|
|
}
|
|
|
|
module.exports = {
|
|
getSimilarNotes
|
|
}; |