Skip to content

Commit

Permalink
Send group call events to linked devices
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanHahn-Signal committed Dec 9, 2020
1 parent 496bdec commit a142cb5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
4 changes: 2 additions & 2 deletions ts/groups.ts
Expand Up @@ -1084,7 +1084,7 @@ export async function initiateMigrationToGroupV2(
});
}

async function wrapWithSyncMessageSend({
export async function wrapWithSyncMessageSend({
conversation,
logId,
send,
Expand All @@ -1094,7 +1094,7 @@ async function wrapWithSyncMessageSend({
logId: string;
send: (sender: MessageSender) => Promise<CallbackResultType | undefined>;
timestamp: number;
}) {
}): Promise<void> {
const sender = window.textsecure.messaging;
if (!sender) {
throw new Error(
Expand Down
22 changes: 16 additions & 6 deletions ts/services/calling.ts
Expand Up @@ -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';

Expand Down Expand Up @@ -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<void> {
Expand Down
14 changes: 9 additions & 5 deletions ts/textsecure/SendMessage.ts
Expand Up @@ -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<void> {
await this.sendMessageToGroup(
): Promise<CallbackResultType> {
return this.sendMessageToGroup(
{
groupV2,
groupCallUpdate: { eraId },
timestamp: Date.now(),
timestamp,
},
options
);
Expand Down

0 comments on commit a142cb5

Please sign in to comment.