Add Message.createAttachmentLoader
This commit is contained in:
@@ -177,6 +177,16 @@ exports.upgradeSchema = async (message, { writeNewAttachmentData } = {}) => {
|
||||
);
|
||||
};
|
||||
|
||||
exports.createAttachmentLoader = (loadAttachmentData) => {
|
||||
if (!isFunction(loadAttachmentData)) {
|
||||
throw new TypeError('`loadAttachmentData` is required');
|
||||
}
|
||||
|
||||
return async message => (Object.assign({}, message, {
|
||||
attachments: await Promise.all(message.attachments.map(loadAttachmentData)),
|
||||
}));
|
||||
};
|
||||
|
||||
// createImporter :: (RelativePath -> IO Unit)
|
||||
// Message ->
|
||||
// IO (Promise Message)
|
||||
|
@@ -143,6 +143,7 @@ window.Signal.Migrations.getPlaceholderMigrations = getPlaceholderMigrations;
|
||||
window.Signal.Migrations.importMessage =
|
||||
Message.createImporter(writeExistingAttachmentData);
|
||||
window.Signal.Migrations.loadAttachmentData = loadAttachmentData;
|
||||
window.Signal.Migrations.loadMessage = Message.createAttachmentLoader(loadAttachmentData);
|
||||
window.Signal.Migrations.Migrations0DatabaseWithAttachmentData =
|
||||
require('./js/modules/migrations/migrations_0_database_with_attachment_data');
|
||||
window.Signal.Migrations.Migrations1DatabaseWithoutAttachmentData =
|
||||
|
Reference in New Issue
Block a user