fix(server): saving revision of note with empty title not supported (closes #6103)

This commit is contained in:
Elian Doran 2025-06-27 14:22:08 +03:00
parent 45a3fb15e6
commit 256ffe39f2
No known key found for this signature in database
2 changed files with 25 additions and 3 deletions

View 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();
});
});

View File

@ -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 = "";
}
}