Improve `Message.upgradeSchema
preconditions
This commit is contained in:
parent
ca28f3030b
commit
4651cbc2eb
2 changed files with 8 additions and 3 deletions
|
@ -14,7 +14,7 @@
|
||||||
;(function() {
|
;(function() {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { IdleDetector } = Signal;
|
const { IdleDetector, MessageMigration } = Signal;
|
||||||
const { Errors, Message } = window.Signal.Types;
|
const { Errors, Message } = window.Signal.Types;
|
||||||
const { upgradeMessageSchema } = window.Signal.Migrations;
|
const { upgradeMessageSchema } = window.Signal.Migrations;
|
||||||
|
|
||||||
|
|
|
@ -166,8 +166,13 @@ const toVersion3 = exports._withSchemaVersion(
|
||||||
);
|
);
|
||||||
|
|
||||||
// UpgradeStep
|
// UpgradeStep
|
||||||
exports.upgradeSchema = async (message, { writeAttachmentData } = {}) =>
|
exports.upgradeSchema = async (message, { writeAttachmentData } = {}) => {
|
||||||
toVersion3(
|
if (!isFunction(writeAttachmentData)) {
|
||||||
|
throw new TypeError('`context.writeAttachmentData` is required');
|
||||||
|
}
|
||||||
|
|
||||||
|
return toVersion3(
|
||||||
await toVersion2(await toVersion1(await toVersion0(message))),
|
await toVersion2(await toVersion1(await toVersion0(message))),
|
||||||
{ writeAttachmentData }
|
{ writeAttachmentData }
|
||||||
);
|
);
|
||||||
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue