From a142cb522eb43f6916f901e64e720da6e2f043eb Mon Sep 17 00:00:00 2001 From: Evan Hahn <69474926+EvanHahn-Signal@users.noreply.github.com> Date: Wed, 9 Dec 2020 16:02:50 -0600 Subject: [PATCH] Send group call events to linked devices --- ts/groups.ts | 4 ++-- ts/services/calling.ts | 22 ++++++++++++++++------ ts/textsecure/SendMessage.ts | 14 +++++++++----- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/ts/groups.ts b/ts/groups.ts index 18f5e1db5bd..72184f9854c 100644 --- a/ts/groups.ts +++ b/ts/groups.ts @@ -1084,7 +1084,7 @@ export async function initiateMigrationToGroupV2( }); } -async function wrapWithSyncMessageSend({ +export async function wrapWithSyncMessageSend({ conversation, logId, send, @@ -1094,7 +1094,7 @@ async function wrapWithSyncMessageSend({ logId: string; send: (sender: MessageSender) => Promise; timestamp: number; -}) { +}): Promise { const sender = window.textsecure.messaging; if (!sender) { throw new Error( diff --git a/ts/services/calling.ts b/ts/services/calling.ts index e28bd66f1f3..2e59e2c0d47 100644 --- a/ts/services/calling.ts +++ b/ts/services/calling.ts @@ -51,7 +51,11 @@ import { arrayBufferToUuid, } from '../Crypto'; import { getOwn } from '../util/getOwn'; -import { fetchMembershipProof, getMembershipList } from '../groups'; +import { + fetchMembershipProof, + getMembershipList, + wrapWithSyncMessageSend, +} from '../groups'; import { missingCaseError } from '../util/missingCaseError'; import { normalizeGroupCallTimestamp } from '../util/ringrtc/normalizeGroupCallTimestamp'; @@ -706,12 +710,18 @@ export class CallingClass { return; } + const timestamp = Date.now(); + // We "fire and forget" because sending this message is non-essential. - window.textsecure.messaging - .sendGroupCallUpdate({ eraId, groupV2 }, sendOptions) - .catch(err => { - window.log.error('Failed to send group call update', err); - }); + wrapWithSyncMessageSend({ + conversation, + logId: `sendGroupCallUpdateMessage/${conversationId}-${eraId}`, + send: sender => + sender.sendGroupCallUpdate({ eraId, groupV2, timestamp }, sendOptions), + timestamp, + }).catch(err => { + window.log.error('Failed to send group call update', err); + }); } async accept(conversationId: string, asVideoCall: boolean): Promise { diff --git a/ts/textsecure/SendMessage.ts b/ts/textsecure/SendMessage.ts index fadb7379e48..1b4f1537845 100644 --- a/ts/textsecure/SendMessage.ts +++ b/ts/textsecure/SendMessage.ts @@ -1143,15 +1143,19 @@ export default class MessageSender { ); } - async sendGroupCallUpdate( - { groupV2, eraId }: { groupV2: GroupV2InfoType; eraId: string }, + sendGroupCallUpdate( + { + groupV2, + eraId, + timestamp, + }: { groupV2: GroupV2InfoType; eraId: string; timestamp: number }, options?: SendOptionsType - ): Promise { - await this.sendMessageToGroup( + ): Promise { + return this.sendMessageToGroup( { groupV2, groupCallUpdate: { eraId }, - timestamp: Date.now(), + timestamp, }, options );