New queue for view once syncs, handleRetry improvements

This commit is contained in:
Scott Nonnenberg 2022-02-08 09:30:42 -08:00 committed by GitHub
parent 571ee3cab6
commit 0a18cc50bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 271 additions and 115 deletions

View file

@ -143,6 +143,7 @@ import {
isQuoteAMatch,
} from '../messages/helpers';
import type { ReplacementValuesType } from '../types/I18N';
import { viewOnceOpenJobQueue } from '../jobs/viewOnceOpenJobQueue';
/* eslint-disable camelcase */
/* eslint-disable more/no-then */
@ -843,20 +844,14 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
await this.eraseContents();
if (!fromSync) {
const sender = getSource(this.attributes);
const senderE164 = getSource(this.attributes);
const senderUuid = getSourceUuid(this.attributes);
const timestamp = this.get('sent_at');
if (senderUuid === undefined) {
throw new Error('senderUuid is undefined');
throw new Error('markViewOnceMessageViewed: senderUuid is undefined');
}
const timestamp = this.get('sent_at');
const ourConversation =
window.ConversationController.getOurConversationOrThrow();
const sendOptions = await getSendOptions(ourConversation.attributes, {
syncMessage: true,
});
if (window.ConversationController.areWePrimaryDevice()) {
log.warn(
'markViewOnceMessageViewed: We are primary device; not sending view once open sync'
@ -864,15 +859,22 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
return;
}
await handleMessageSend(
window.textsecure.messaging.syncViewOnceOpen(
sender,
senderUuid,
timestamp,
sendOptions
),
{ messageIds: [this.id], sendType: 'viewOnceSync' }
);
try {
await viewOnceOpenJobQueue.add({
viewOnceOpens: [
{
senderE164,
senderUuid,
timestamp,
},
],
});
} catch (error) {
log.error(
'markViewOnceMessageViewed: Failed to queue view once open sync',
Errors.toLogFormat(error)
);
}
}
}