mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	fix(server): saving revision of note with empty title not supported (closes #6103)
This commit is contained in:
		
							
								
								
									
										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, |             type: this.type, | ||||||
|             mime: this.mime, |             mime: this.mime, | ||||||
|             isProtected: this.isProtected, |             isProtected: this.isProtected, | ||||||
|             title: this.title || undefined, |             title: this.title, | ||||||
|             blobId: this.blobId, |             blobId: this.blobId, | ||||||
|             dateLastEdited: this.dateLastEdited, |             dateLastEdited: this.dateLastEdited, | ||||||
|             dateCreated: this.dateCreated, |             dateCreated: this.dateCreated, | ||||||
| @@ -211,10 +211,10 @@ class BRevision extends AbstractBeccaEntity<BRevision> { | |||||||
|  |  | ||||||
|         if (pojo.isProtected) { |         if (pojo.isProtected) { | ||||||
|             if (protectedSessionService.isProtectedSessionAvailable()) { |             if (protectedSessionService.isProtectedSessionAvailable()) { | ||||||
|                 pojo.title = protectedSessionService.encrypt(this.title) || undefined; |                 pojo.title = protectedSessionService.encrypt(this.title) ?? ""; | ||||||
|             } else { |             } else { | ||||||
|                 // updating protected note outside of protected session means we will keep original ciphertexts |                 // updating protected note outside of protected session means we will keep original ciphertexts | ||||||
|                 delete pojo.title; |                 pojo.title = ""; | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user