Move a number of sync messages to jobs for retry
This commit is contained in:
parent
74aaf7819a
commit
90356d4c0f
19 changed files with 501 additions and 373 deletions
|
@ -1,4 +1,4 @@
|
|||
// Copyright 2020-2021 Signal Messenger, LLC
|
||||
// Copyright 2020-2022 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { debounce, isNumber } from 'lodash';
|
||||
|
@ -27,7 +27,6 @@ import type { ConversationModel } from '../models/conversations';
|
|||
import { strictAssert } from '../util/assert';
|
||||
import * as durations from '../util/durations';
|
||||
import { BackOff } from '../util/BackOff';
|
||||
import { handleMessageSend } from '../util/handleMessageSend';
|
||||
import { storageJobQueue } from '../util/JobQueue';
|
||||
import { sleep } from '../util/sleep';
|
||||
import { isMoreRecentThan } from '../util/timestamp';
|
||||
|
@ -39,6 +38,8 @@ import {
|
|||
} from '../util/whatTypeOfConversation';
|
||||
import { SignalService as Proto } from '../protobuf';
|
||||
import * as log from '../logging/log';
|
||||
import { singleProtoJobQueue } from '../jobs/singleProtoJobQueue';
|
||||
import * as Errors from '../types/errors';
|
||||
|
||||
type IManifestRecordIdentifier = Proto.ManifestRecord.IIdentifier;
|
||||
|
||||
|
@ -553,15 +554,21 @@ async function uploadManifest(
|
|||
|
||||
if (window.ConversationController.areWePrimaryDevice()) {
|
||||
log.warn(
|
||||
'uploadManifest: We are primary device; not sending sync manifest'
|
||||
'storageService.uploadManifest: We are primary device; not sending sync manifest'
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
await handleMessageSend(
|
||||
window.textsecure.messaging.sendFetchManifestSyncMessage(),
|
||||
{ messageIds: [], sendType: 'otherSync' }
|
||||
);
|
||||
try {
|
||||
await singleProtoJobQueue.add(
|
||||
window.textsecure.messaging.getFetchManifestSyncMessage()
|
||||
);
|
||||
} catch (error) {
|
||||
log.error(
|
||||
'storageService.uploadManifest: Failed to queue sync message',
|
||||
Errors.toLogFormat(error)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async function stopStorageServiceSync() {
|
||||
|
@ -578,7 +585,7 @@ async function stopStorageServiceSync() {
|
|||
|
||||
await sleep(backOff.getAndIncrement());
|
||||
log.info('storageService.stopStorageServiceSync: requesting new keys');
|
||||
setTimeout(() => {
|
||||
setTimeout(async () => {
|
||||
if (!window.textsecure.messaging) {
|
||||
throw new Error('storageService.stopStorageServiceSync: We are offline!');
|
||||
}
|
||||
|
@ -589,11 +596,16 @@ async function stopStorageServiceSync() {
|
|||
);
|
||||
return;
|
||||
}
|
||||
|
||||
handleMessageSend(window.textsecure.messaging.sendRequestKeySyncMessage(), {
|
||||
messageIds: [],
|
||||
sendType: 'otherSync',
|
||||
});
|
||||
try {
|
||||
await singleProtoJobQueue.add(
|
||||
window.textsecure.messaging.getRequestKeySyncMessage()
|
||||
);
|
||||
} catch (error) {
|
||||
log.error(
|
||||
'storageService.stopStorageServiceSync: Failed to queue sync message',
|
||||
Errors.toLogFormat(error)
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1118,14 +1130,23 @@ async function upload(fromSync = false): Promise<void> {
|
|||
backOff.reset();
|
||||
|
||||
if (window.ConversationController.areWePrimaryDevice()) {
|
||||
log.warn('upload: We are primary device; not sending key sync request');
|
||||
log.warn(
|
||||
'storageService.upload: We are primary device; not sending key sync request'
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
await handleMessageSend(
|
||||
window.textsecure.messaging.sendRequestKeySyncMessage(),
|
||||
{ messageIds: [], sendType: 'otherSync' }
|
||||
);
|
||||
try {
|
||||
await singleProtoJobQueue.add(
|
||||
window.textsecure.messaging.getRequestKeySyncMessage()
|
||||
);
|
||||
} catch (error) {
|
||||
log.error(
|
||||
'storageService.upload: Failed to queue sync message',
|
||||
Errors.toLogFormat(error)
|
||||
);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue