mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 13:01:31 +08:00 
			
		
		
		
	server-ts: Convert blob.js
This commit is contained in:
		
							parent
							
								
									85af0a24ee
								
							
						
					
					
						commit
						cb14d4d8f9
					
				| @ -1,9 +1,9 @@ | |||||||
| const becca = require('../becca/becca.js'); | import becca = require('../becca/becca.js'); | ||||||
| const NotFoundError = require('../errors/not_found_error.js'); | import NotFoundError = require('../errors/not_found_error'); | ||||||
| const protectedSessionService = require('./protected_session.js'); | import protectedSessionService = require('./protected_session'); | ||||||
| const utils = require('./utils'); | import utils = require('./utils'); | ||||||
| 
 | 
 | ||||||
| function getBlobPojo(entityName, entityId) { | function getBlobPojo(entityName: string, entityId: string) { | ||||||
|     const entity = becca.getEntity(entityName, entityId); |     const entity = becca.getEntity(entityName, entityId); | ||||||
|     if (!entity) { |     if (!entity) { | ||||||
|         throw new NotFoundError(`Entity ${entityName} '${entityId}' was not found.`); |         throw new NotFoundError(`Entity ${entityName} '${entityId}' was not found.`); | ||||||
| @ -25,7 +25,7 @@ function getBlobPojo(entityName, entityId) { | |||||||
|     return pojo; |     return pojo; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function processContent(content, isProtected, isStringContent) { | function processContent(content: Buffer | string | null, isProtected: boolean, isStringContent: boolean) { | ||||||
|     if (isProtected) { |     if (isProtected) { | ||||||
|         if (protectedSessionService.isProtectedSessionAvailable()) { |         if (protectedSessionService.isProtectedSessionAvailable()) { | ||||||
|             content = content === null ? null : protectedSessionService.decrypt(content); |             content = content === null ? null : protectedSessionService.decrypt(content); | ||||||
| @ -48,7 +48,7 @@ function processContent(content, isProtected, isStringContent) { | |||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function calculateContentHash({blobId, content}) { | function calculateContentHash({blobId, content}: { blobId: string, content: Buffer }) { | ||||||
|     return utils.hash(`${blobId}|${content.toString()}`); |     return utils.hash(`${blobId}|${content.toString()}`); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Elian Doran
						Elian Doran