Request configuration sync on startup of new version
This commit is contained in:
parent
f5954db711
commit
313d08344a
6 changed files with 17 additions and 243 deletions
|
@ -9,7 +9,6 @@ const IndexedDB = require('./indexeddb');
|
|||
const Notifications = require('../../ts/notifications');
|
||||
const OS = require('../../ts/OS');
|
||||
const Settings = require('./settings');
|
||||
const Startup = require('./startup');
|
||||
const Util = require('../../ts/util');
|
||||
const { migrateToSQL } = require('./migrate_to_sql');
|
||||
const Metadata = require('./metadata/SecretSessionCipher');
|
||||
|
@ -233,7 +232,6 @@ exports.setup = (options = {}) => {
|
|||
OS,
|
||||
RefreshSenderCertificate,
|
||||
Settings,
|
||||
Startup,
|
||||
Types,
|
||||
Util,
|
||||
Views,
|
||||
|
|
|
@ -1,65 +0,0 @@
|
|||
const is = require('@sindresorhus/is');
|
||||
|
||||
const Errors = require('./types/errors');
|
||||
const Settings = require('./settings');
|
||||
|
||||
exports.syncReadReceiptConfiguration = async ({
|
||||
ourNumber,
|
||||
deviceId,
|
||||
sendRequestConfigurationSyncMessage,
|
||||
storage,
|
||||
prepareForSend,
|
||||
}) => {
|
||||
if (!is.string(deviceId)) {
|
||||
throw new TypeError('deviceId is required');
|
||||
}
|
||||
if (!is.function(sendRequestConfigurationSyncMessage)) {
|
||||
throw new TypeError('sendRequestConfigurationSyncMessage is required');
|
||||
}
|
||||
if (!is.function(prepareForSend)) {
|
||||
throw new TypeError('prepareForSend is required');
|
||||
}
|
||||
|
||||
if (!is.string(ourNumber)) {
|
||||
throw new TypeError('ourNumber is required');
|
||||
}
|
||||
|
||||
if (!is.object(storage)) {
|
||||
throw new TypeError('storage is required');
|
||||
}
|
||||
|
||||
const isPrimaryDevice = deviceId === '1';
|
||||
if (isPrimaryDevice) {
|
||||
return {
|
||||
status: 'skipped',
|
||||
reason: 'isPrimaryDevice',
|
||||
};
|
||||
}
|
||||
|
||||
const settingName = Settings.READ_RECEIPT_CONFIGURATION_SYNC;
|
||||
const hasPreviouslySynced = Boolean(storage.get(settingName));
|
||||
if (hasPreviouslySynced) {
|
||||
return {
|
||||
status: 'skipped',
|
||||
reason: 'hasPreviouslySynced',
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
const { wrap, sendOptions } = prepareForSend(ourNumber, {
|
||||
syncMessage: true,
|
||||
});
|
||||
await wrap(sendRequestConfigurationSyncMessage(sendOptions));
|
||||
storage.put(settingName, true);
|
||||
} catch (error) {
|
||||
return {
|
||||
status: 'error',
|
||||
reason: 'failedToSendSyncMessage',
|
||||
error: Errors.toLogFormat(error),
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
status: 'complete',
|
||||
};
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue