Merge remote-tracking branch 'origin/develop' into feature/port_0.63.7

This commit is contained in:
Elian Doran
2024-07-14 09:58:37 +03:00
16 changed files with 218 additions and 33 deletions

View File

@@ -20,7 +20,7 @@ import BNote = require('../../becca/entities/bnote');
import NoteMeta = require('../meta/note_meta');
import AttributeMeta = require('../meta/attribute_meta');
import { Stream } from 'stream';
import { NoteType } from '../../becca/entities/rows';
import { ALLOWED_NOTE_TYPES, NoteType } from '../../becca/entities/rows';
interface MetaFile {
files: NoteMeta[]
@@ -499,10 +499,6 @@ async function importZip(taskContext: TaskContext, fileBuffer: Buffer, importRoo
}
}
else {
if (typeof content !== "string") {
throw new Error("Incorrect content type.");
}
({note} = noteService.createNewNote({
parentNoteId: parentNoteId,
title: noteTitle || "",
@@ -653,7 +649,11 @@ function resolveNoteType(type: string | undefined): NoteType {
return 'webView';
}
return "text";
if (type && (ALLOWED_NOTE_TYPES as readonly string[]).includes(type)) {
return type as NoteType;
} else {
return "text";
}
}
export = {

View File

@@ -7,7 +7,7 @@ export interface NoteParams {
parentNoteId: string;
templateNoteId?: string;
title: string;
content: string;
content: string | Buffer;
/** text, code, file, image, search, book, relationMap, canvas, webView */
type: NoteType;
/** default value is derived from default mimes for type */

View File

@@ -74,7 +74,7 @@ class NoteContentFulltextExp extends Expression {
}
if (isProtected) {
if (!protectedSessionService.isProtectedSessionAvailable() || !content) {
if (!protectedSessionService.isProtectedSessionAvailable() || !content || typeof content !== "string") {
return;
}
@@ -86,7 +86,7 @@ class NoteContentFulltextExp extends Expression {
}
}
if (!content) {
if (!content || typeof content !== "string") {
return;
}