Only notify for group calls once
This commit is contained in:
parent
3268d3e6eb
commit
1f963efd64
3 changed files with 53 additions and 28 deletions
|
@ -113,7 +113,7 @@ import {
|
||||||
getLocalCallEventFromCallEndedReason,
|
getLocalCallEventFromCallEndedReason,
|
||||||
getCallDetailsFromEndedDirectCall,
|
getCallDetailsFromEndedDirectCall,
|
||||||
getCallEventDetails,
|
getCallEventDetails,
|
||||||
getLocalCallEventFromGroupCall,
|
getLocalCallEventFromJoinState,
|
||||||
getLocalCallEventFromDirectCall,
|
getLocalCallEventFromDirectCall,
|
||||||
getCallDetailsFromDirectCall,
|
getCallDetailsFromDirectCall,
|
||||||
getCallDetailsFromGroupCallMeta,
|
getCallDetailsFromGroupCallMeta,
|
||||||
|
@ -121,6 +121,7 @@ import {
|
||||||
getGroupCallMeta,
|
getGroupCallMeta,
|
||||||
getCallIdFromRing,
|
getCallIdFromRing,
|
||||||
getLocalCallEventFromRingUpdate,
|
getLocalCallEventFromRingUpdate,
|
||||||
|
convertJoinState,
|
||||||
} from '../util/callDisposition';
|
} from '../util/callDisposition';
|
||||||
import { isNormalNumber } from '../util/isNormalNumber';
|
import { isNormalNumber } from '../util/isNormalNumber';
|
||||||
import { LocalCallEvent } from '../types/CallDisposition';
|
import { LocalCallEvent } from '../types/CallDisposition';
|
||||||
|
@ -718,8 +719,8 @@ export class CallingClass {
|
||||||
|
|
||||||
if (groupCallMeta != null) {
|
if (groupCallMeta != null) {
|
||||||
try {
|
try {
|
||||||
const localCallEvent = getLocalCallEventFromGroupCall(
|
const localCallEvent = getLocalCallEventFromJoinState(
|
||||||
groupCall,
|
convertJoinState(localDeviceState.joinState),
|
||||||
groupCallMeta
|
groupCallMeta
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -844,7 +845,11 @@ export class CallingClass {
|
||||||
void this.sendGroupCallUpdateMessage(conversationId, eraId);
|
void this.sendGroupCallUpdateMessage(conversationId, eraId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void this.updateCallHistoryForGroupCall(conversationId, peekInfo);
|
void this.updateCallHistoryForGroupCall(
|
||||||
|
conversationId,
|
||||||
|
convertJoinState(localDeviceState.joinState),
|
||||||
|
peekInfo
|
||||||
|
);
|
||||||
this.syncGroupCallToRedux(conversationId, groupCall);
|
this.syncGroupCallToRedux(conversationId, groupCall);
|
||||||
},
|
},
|
||||||
async requestMembershipProof(groupCall) {
|
async requestMembershipProof(groupCall) {
|
||||||
|
@ -2256,6 +2261,7 @@ export class CallingClass {
|
||||||
|
|
||||||
public async updateCallHistoryForGroupCall(
|
public async updateCallHistoryForGroupCall(
|
||||||
conversationId: string,
|
conversationId: string,
|
||||||
|
joinState: GroupCallJoinState,
|
||||||
peekInfo: PeekInfo | null
|
peekInfo: PeekInfo | null
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const groupCallMeta = getGroupCallMeta(peekInfo);
|
const groupCallMeta = getGroupCallMeta(peekInfo);
|
||||||
|
@ -2282,10 +2288,9 @@ export class CallingClass {
|
||||||
|
|
||||||
const isNewCall = prevMessageId == null;
|
const isNewCall = prevMessageId == null;
|
||||||
|
|
||||||
const groupCall = this.getGroupCall(conversationId);
|
if (isNewCall) {
|
||||||
if (groupCall != null) {
|
const localCallEvent = getLocalCallEventFromJoinState(
|
||||||
const localCallEvent = getLocalCallEventFromGroupCall(
|
joinState,
|
||||||
groupCall,
|
|
||||||
groupCallMeta
|
groupCallMeta
|
||||||
);
|
);
|
||||||
if (localCallEvent != null) {
|
if (localCallEvent != null) {
|
||||||
|
|
|
@ -372,7 +372,13 @@ const doGroupCallPeek = (
|
||||||
`doGroupCallPeek/groupv2(${conversation.groupId}): Found ${peekInfo.deviceCount} devices`
|
`doGroupCallPeek/groupv2(${conversation.groupId}): Found ${peekInfo.deviceCount} devices`
|
||||||
);
|
);
|
||||||
|
|
||||||
await calling.updateCallHistoryForGroupCall(conversationId, peekInfo);
|
if (existingCall?.callMode === CallMode.Group) {
|
||||||
|
await calling.updateCallHistoryForGroupCall(
|
||||||
|
conversationId,
|
||||||
|
existingCall.joinState,
|
||||||
|
peekInfo
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const formattedPeekInfo = calling.formatGroupCallPeekInfoForRedux(peekInfo);
|
const formattedPeekInfo = calling.formatGroupCallPeekInfoForRedux(peekInfo);
|
||||||
|
|
||||||
|
|
|
@ -2,12 +2,7 @@
|
||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
import Long from 'long';
|
import Long from 'long';
|
||||||
import type {
|
import type { Call, PeekInfo, LocalDeviceState } from '@signalapp/ringrtc';
|
||||||
Call,
|
|
||||||
GroupCall,
|
|
||||||
PeekInfo,
|
|
||||||
LocalDeviceState,
|
|
||||||
} from '@signalapp/ringrtc';
|
|
||||||
import {
|
import {
|
||||||
CallState,
|
CallState,
|
||||||
ConnectionState,
|
ConnectionState,
|
||||||
|
@ -21,7 +16,11 @@ import { strictAssert } from './assert';
|
||||||
import { SignalService as Proto } from '../protobuf';
|
import { SignalService as Proto } from '../protobuf';
|
||||||
import { bytesToUuid, uuidToBytes } from './uuidToBytes';
|
import { bytesToUuid, uuidToBytes } from './uuidToBytes';
|
||||||
import { missingCaseError } from './missingCaseError';
|
import { missingCaseError } from './missingCaseError';
|
||||||
import { CallEndedReason, CallMode } from '../types/Calling';
|
import {
|
||||||
|
CallEndedReason,
|
||||||
|
CallMode,
|
||||||
|
GroupCallJoinState,
|
||||||
|
} from '../types/Calling';
|
||||||
import type { ServiceIdString } from '../types/ServiceId';
|
import type { ServiceIdString } from '../types/ServiceId';
|
||||||
import { isMe } from './whatTypeOfConversation';
|
import { isMe } from './whatTypeOfConversation';
|
||||||
import * as log from '../logging/log';
|
import * as log from '../logging/log';
|
||||||
|
@ -137,6 +136,22 @@ export function getPeerIdFromConversation(
|
||||||
return conversation.groupId;
|
return conversation.groupId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function convertJoinState(joinState: JoinState): GroupCallJoinState {
|
||||||
|
if (joinState === JoinState.Joined) {
|
||||||
|
return GroupCallJoinState.Joined;
|
||||||
|
}
|
||||||
|
if (joinState === JoinState.Joining) {
|
||||||
|
return GroupCallJoinState.Joining;
|
||||||
|
}
|
||||||
|
if (joinState === JoinState.NotJoined) {
|
||||||
|
return GroupCallJoinState.NotJoined;
|
||||||
|
}
|
||||||
|
if (joinState === JoinState.Pending) {
|
||||||
|
return GroupCallJoinState.Pending;
|
||||||
|
}
|
||||||
|
throw missingCaseError(joinState);
|
||||||
|
}
|
||||||
|
|
||||||
// Call Events <-> Protos
|
// Call Events <-> Protos
|
||||||
// ----------------------
|
// ----------------------
|
||||||
|
|
||||||
|
@ -331,34 +346,33 @@ export function getLocalCallEventFromRingUpdate(
|
||||||
return ringUpdateToEvent[update];
|
return ringUpdateToEvent[update];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getLocalCallEventFromGroupCall(
|
export function getLocalCallEventFromJoinState(
|
||||||
groupCall: GroupCall,
|
joinState: GroupCallJoinState,
|
||||||
groupCallMeta: GroupCallMeta
|
groupCallMeta: GroupCallMeta
|
||||||
): LocalCallEvent | null {
|
): LocalCallEvent | null {
|
||||||
const direction = getCallDirectionFromRingerId(groupCallMeta.ringerId);
|
const direction = getCallDirectionFromRingerId(groupCallMeta.ringerId);
|
||||||
const localDeviceState = groupCall.getLocalDeviceState();
|
|
||||||
log.info(
|
log.info(
|
||||||
'getLocalCallEventFromGroupCall',
|
'getLocalCallEventFromGroupCall',
|
||||||
direction,
|
direction,
|
||||||
JoinState[localDeviceState.joinState]
|
GroupCallJoinState[joinState]
|
||||||
);
|
);
|
||||||
if (direction === CallDirection.Incoming) {
|
if (direction === CallDirection.Incoming) {
|
||||||
if (localDeviceState.joinState === JoinState.Joined) {
|
if (joinState === GroupCallJoinState.Joined) {
|
||||||
return LocalCallEvent.Accepted;
|
return LocalCallEvent.Accepted;
|
||||||
}
|
}
|
||||||
if (localDeviceState.joinState === JoinState.NotJoined) {
|
if (joinState === GroupCallJoinState.NotJoined) {
|
||||||
return null; // Group calls shouldn't send "NotAccepted"
|
return LocalCallEvent.Started;
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
localDeviceState.joinState === JoinState.Joining ||
|
joinState === GroupCallJoinState.Joining ||
|
||||||
localDeviceState.joinState === JoinState.Pending
|
joinState === GroupCallJoinState.Pending
|
||||||
) {
|
) {
|
||||||
return LocalCallEvent.Accepted;
|
return LocalCallEvent.Accepted;
|
||||||
}
|
}
|
||||||
throw missingCaseError(localDeviceState.joinState);
|
throw missingCaseError(joinState);
|
||||||
} else {
|
} else {
|
||||||
if (localDeviceState.joinState === JoinState.NotJoined) {
|
if (joinState === GroupCallJoinState.NotJoined) {
|
||||||
return LocalCallEvent.Hangup;
|
return LocalCallEvent.Started;
|
||||||
}
|
}
|
||||||
return LocalCallEvent.Ringing;
|
return LocalCallEvent.Ringing;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue