|  |  | @ -84,31 +84,39 @@ export const getDecryptedMediaUrl = async ( | 
			
		
	
		
		
			
				
					
					|  |  |  |       urlToDecryptingPromise.set( |  |  |  |       urlToDecryptingPromise.set( | 
			
		
	
		
		
			
				
					
					|  |  |  |         url, |  |  |  |         url, | 
			
		
	
		
		
			
				
					
					|  |  |  |         new Promise(async resolve => { |  |  |  |         new Promise(async resolve => { | 
			
		
	
		
		
			
				
					
					|  |  |  |           const encryptedFileContent = await fse.readFile(url); |  |  |  |           window.log.info('about to read and decrypt file :', url); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |           const decryptedContent = await decryptAttachmentBuffer( |  |  |  |           try { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             toArrayBuffer(encryptedFileContent) |  |  |  |             const encryptedFileContent = await fse.readFile(url); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |           ); |  |  |  |             const decryptedContent = await decryptAttachmentBuffer( | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |           if (decryptedContent?.length) { |  |  |  |               toArrayBuffer(encryptedFileContent) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             const arrayBuffer = decryptedContent.buffer; |  |  |  |             ); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             const { makeObjectUrl } = window.Signal.Types.VisualAttachment; |  |  |  |             if (decryptedContent?.length) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             const obj = makeObjectUrl(arrayBuffer, contentType); |  |  |  |               const arrayBuffer = decryptedContent.buffer; | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |               const { makeObjectUrl } = window.Signal.Types.VisualAttachment; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |               const obj = makeObjectUrl(arrayBuffer, contentType); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             if (!urlToDecryptedBlobMap.has(url)) { |  |  |  |               if (!urlToDecryptedBlobMap.has(url)) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |               urlToDecryptedBlobMap.set(url, { |  |  |  |                 urlToDecryptedBlobMap.set(url, { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 decrypted: obj, |  |  |  |                   decrypted: obj, | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 lastAccessTimestamp: Date.now(), |  |  |  |                   lastAccessTimestamp: Date.now(), | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 forceRetain: isAvatar, |  |  |  |                   forceRetain: isAvatar, | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |               }); |  |  |  |                 }); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |               } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |               window.log.info(' file decrypted :', url); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |               urlToDecryptingPromise.delete(url); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |               resolve(obj); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |               return; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             } else { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |               // failed to decrypt, fallback to url image loading
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |               // it might be a media we received before the update encrypting attachments locally.
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |               urlToDecryptingPromise.delete(url); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |               window.log.info('error decrypting file :', url); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |               resolve(url); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |               return; | 
			
		
	
		
		
			
				
					
					|  |  |  |             } |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |             urlToDecryptingPromise.delete(url); |  |  |  |           } catch (e) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             resolve(obj); |  |  |  |             window.log.warn(e); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             return; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |           } else { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             // failed to decrypt, fallback to url image loading
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             // it might be a media we received before the update encrypting attachments locally.
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             urlToDecryptingPromise.delete(url); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             resolve(url); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             return; |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |           } |  |  |  |           } | 
			
		
	
		
		
			
				
					
					|  |  |  |         }) |  |  |  |         }) | 
			
		
	
		
		
			
				
					
					|  |  |  |       ); |  |  |  |       ); | 
			
		
	
	
		
		
			
				
					|  |  | 
 |