mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 15:19:01 +02:00
fix(server): saving revision of note with empty title not supported (closes #6103)
This commit is contained in:
parent
45a3fb15e6
commit
256ffe39f2
22
apps/server/src/becca/entities/brevision.spec.ts
Normal file
22
apps/server/src/becca/entities/brevision.spec.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import BRevision from "./brevision.js";
|
||||
|
||||
describe("Revision", () => {
|
||||
it("handles note with empty title properly", () => {
|
||||
const revision = new BRevision({
|
||||
revisionId: "4omM5OvlLhOw",
|
||||
noteId: "WHMg7iFCRG3Z",
|
||||
type: "text",
|
||||
mime: "text/html",
|
||||
isProtected: false,
|
||||
title: "",
|
||||
blobId: "",
|
||||
dateLastEdited: "2025-06-27 14:10:39.688+0300",
|
||||
dateCreated: "2025-06-27 14:10:39.688+0300",
|
||||
utcDateLastEdited: "2025-06-27 14:10:39.688+0300",
|
||||
utcDateCreated: "2025-06-27 14:10:39.688+0300",
|
||||
utcDateModified: "2025-06-27 14:10:39.688+0300"
|
||||
});
|
||||
const pojo = revision.getPojo();
|
||||
expect(pojo.title).toBeDefined();
|
||||
});
|
||||
});
|
@ -192,7 +192,7 @@ class BRevision extends AbstractBeccaEntity<BRevision> {
|
||||
type: this.type,
|
||||
mime: this.mime,
|
||||
isProtected: this.isProtected,
|
||||
title: this.title || undefined,
|
||||
title: this.title,
|
||||
blobId: this.blobId,
|
||||
dateLastEdited: this.dateLastEdited,
|
||||
dateCreated: this.dateCreated,
|
||||
@ -211,10 +211,10 @@ class BRevision extends AbstractBeccaEntity<BRevision> {
|
||||
|
||||
if (pojo.isProtected) {
|
||||
if (protectedSessionService.isProtectedSessionAvailable()) {
|
||||
pojo.title = protectedSessionService.encrypt(this.title) || undefined;
|
||||
pojo.title = protectedSessionService.encrypt(this.title) ?? "";
|
||||
} else {
|
||||
// updating protected note outside of protected session means we will keep original ciphertexts
|
||||
delete pojo.title;
|
||||
pojo.title = "";
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user