search note content only if not excluded by other expressions

This commit is contained in:
zadam 2020-12-25 20:46:04 +01:00
parent 4f27254e64
commit e89057a771
2 changed files with 11 additions and 11 deletions

View File

@ -32,11 +32,15 @@ class NoteContentProtectedFulltextExp extends Expression {
FROM notes JOIN note_contents USING (noteId)
WHERE type IN ('text', 'code') AND isDeleted = 0 AND isProtected = 1`)) {
if (!inputNoteSet.hasNoteId(noteId) || !(noteId in noteCache.notes)) {
continue;
}
try {
content = protectedSessionService.decryptString(content);
}
catch (e) {
log.info('Cannot decrypt content of note', noteId);
log.info(`Cannot decrypt content of note ${noteId}`);
continue;
}
@ -50,11 +54,7 @@ class NoteContentProtectedFulltextExp extends Expression {
content = content.replace(/ /g, ' ');
}
if (this.tokens.find(token => !content.includes(token))) {
continue;
}
if (inputNoteSet.hasNoteId(noteId) && noteId in noteCache.notes) {
if (!this.tokens.find(token => !content.includes(token))) {
resultNoteSet.add(noteCache.notes[noteId]);
}
}

View File

@ -26,6 +26,10 @@ class NoteContentUnprotectedFulltextExp extends Expression {
FROM notes JOIN note_contents USING (noteId)
WHERE type IN ('text', 'code') AND isDeleted = 0 AND isProtected = 0`)) {
if (!inputNoteSet.hasNoteId(noteId) || !(noteId in noteCache.notes)) {
continue;
}
content = content.toString().toLowerCase();
if (type === 'text' && mime === 'text/html') {
@ -36,11 +40,7 @@ class NoteContentUnprotectedFulltextExp extends Expression {
content = content.replace(/ /g, ' ');
}
if (this.tokens.find(token => !content.includes(token))) {
continue;
}
if (inputNoteSet.hasNoteId(noteId) && noteId in noteCache.notes) {
if (!this.tokens.find(token => !content.includes(token))) {
resultNoteSet.add(noteCache.notes[noteId]);
}
}