Rename createImporter to createAttachmentDataWriter
		
	This commit is contained in:
		
					parent
					
						
							
								5ea1a305a6
							
						
					
				
			
			
				commit
				
					
						4c4443390a
					
				
			
		
					 4 changed files with 15 additions and 12 deletions
				
			
		|  | @ -824,9 +824,9 @@ async function saveAllMessages(db, rawMessages) { | ||||||
|     return Promise.resolve(); |     return Promise.resolve(); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   const { importMessage, upgradeMessageSchema } = Signal.Migrations; |   const { writeMessageAttachments, upgradeMessageSchema } = Signal.Migrations; | ||||||
|   const importAndUpgrade = async message => |   const importAndUpgrade = async message => | ||||||
|     upgradeMessageSchema(await importMessage(message)); |     upgradeMessageSchema(await writeMessageAttachments(message)); | ||||||
| 
 | 
 | ||||||
|   const messages = await Promise.all(rawMessages.map(importAndUpgrade)); |   const messages = await Promise.all(rawMessages.map(importAndUpgrade)); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -187,10 +187,10 @@ exports.createAttachmentLoader = (loadAttachmentData) => { | ||||||
|   })); |   })); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| //      createImporter :: (RelativePath -> IO Unit)
 | //      createAttachmentDataWriter :: (RelativePath -> IO Unit)
 | ||||||
| //                                    Message ->
 | //                                    Message ->
 | ||||||
| //                                    IO (Promise Message)
 | //                                    IO (Promise Message)
 | ||||||
| exports.createImporter = (writeExistingAttachmentData) => { | exports.createAttachmentDataWriter = (writeExistingAttachmentData) => { | ||||||
|   if (!isFunction(writeExistingAttachmentData)) { |   if (!isFunction(writeExistingAttachmentData)) { | ||||||
|     throw new TypeError('"writeExistingAttachmentData" must be a function'); |     throw new TypeError('"writeExistingAttachmentData" must be a function'); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  | @ -140,8 +140,8 @@ window.Signal.Migrations = {}; | ||||||
| window.Signal.Migrations.deleteAttachmentData = | window.Signal.Migrations.deleteAttachmentData = | ||||||
|   Attachment.deleteData(deleteAttachmentData); |   Attachment.deleteData(deleteAttachmentData); | ||||||
| window.Signal.Migrations.getPlaceholderMigrations = getPlaceholderMigrations; | window.Signal.Migrations.getPlaceholderMigrations = getPlaceholderMigrations; | ||||||
| window.Signal.Migrations.importMessage = | window.Signal.Migrations.writeMessageAttachments = | ||||||
|   Message.createImporter(writeExistingAttachmentData); |   Message.createAttachmentDataWriter(writeExistingAttachmentData); | ||||||
| window.Signal.Migrations.loadAttachmentData = loadAttachmentData; | window.Signal.Migrations.loadAttachmentData = loadAttachmentData; | ||||||
| window.Signal.Migrations.loadMessage = Message.createAttachmentLoader(loadAttachmentData); | window.Signal.Migrations.loadMessage = Message.createAttachmentLoader(loadAttachmentData); | ||||||
| window.Signal.Migrations.Migrations0DatabaseWithAttachmentData = | window.Signal.Migrations.Migrations0DatabaseWithAttachmentData = | ||||||
|  |  | ||||||
|  | @ -5,7 +5,7 @@ const { stringToArrayBuffer } = require('../../../js/modules/string_to_array_buf | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| describe('Message', () => { | describe('Message', () => { | ||||||
|   describe('createImporter', () => { |   describe('createAttachmentDataWriter', () => { | ||||||
|     it('should ignore messages that didn’t go through attachment migration', async () => { |     it('should ignore messages that didn’t go through attachment migration', async () => { | ||||||
|       const input = { |       const input = { | ||||||
|         body: 'Imagine there is no heaven…', |         body: 'Imagine there is no heaven…', | ||||||
|  | @ -17,7 +17,8 @@ describe('Message', () => { | ||||||
|       }; |       }; | ||||||
|       const writeExistingAttachmentData = () => {}; |       const writeExistingAttachmentData = () => {}; | ||||||
| 
 | 
 | ||||||
|       const actual = await Message.createImporter(writeExistingAttachmentData)(input); |       const actual = | ||||||
|  |         await Message.createAttachmentDataWriter(writeExistingAttachmentData)(input); | ||||||
|       assert.deepEqual(actual, expected); |       assert.deepEqual(actual, expected); | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|  | @ -34,7 +35,8 @@ describe('Message', () => { | ||||||
|       }; |       }; | ||||||
|       const writeExistingAttachmentData = () => {}; |       const writeExistingAttachmentData = () => {}; | ||||||
| 
 | 
 | ||||||
|       const actual = await Message.createImporter(writeExistingAttachmentData)(input); |       const actual = | ||||||
|  |         await Message.createAttachmentDataWriter(writeExistingAttachmentData)(input); | ||||||
|       assert.deepEqual(actual, expected); |       assert.deepEqual(actual, expected); | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|  | @ -60,7 +62,8 @@ describe('Message', () => { | ||||||
|         assert.deepEqual(attachment.data, stringToArrayBuffer('It’s easy if you try')); |         assert.deepEqual(attachment.data, stringToArrayBuffer('It’s easy if you try')); | ||||||
|       }; |       }; | ||||||
| 
 | 
 | ||||||
|       const actual = await Message.createImporter(writeExistingAttachmentData)(input); |       const actual = | ||||||
|  |         await Message.createAttachmentDataWriter(writeExistingAttachmentData)(input); | ||||||
|       assert.deepEqual(actual, expected); |       assert.deepEqual(actual, expected); | ||||||
|     }); |     }); | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Daniel Gasienica
				Daniel Gasienica