services/calling: Make logging consistent in startCall functions
Co-authored-by: Scott Nonnenberg <scott@signal.org>
This commit is contained in:
parent
4172abf4d3
commit
024f30aa3a
2 changed files with 35 additions and 19 deletions
|
@ -881,20 +881,23 @@ export class CallingClass {
|
|||
hasLocalAudio: boolean,
|
||||
hasLocalVideo: boolean
|
||||
): Promise<void> {
|
||||
const logId = 'CallingClass.startOutgoingDirectCall';
|
||||
const conversation = window.ConversationController.get(conversationId);
|
||||
if (!conversation) {
|
||||
log.error(
|
||||
`startOutgoingCall: Could not find conversation ${conversationId}, cannot start call`
|
||||
);
|
||||
this.stopCallingLobby();
|
||||
return;
|
||||
}
|
||||
|
||||
const idForLogging = getConversationIdForLogging(conversation.attributes);
|
||||
const logId = `startOutgoingDirectCall(${idForLogging}`;
|
||||
log.info(logId);
|
||||
|
||||
if (!this.reduxInterface) {
|
||||
throw new Error(`${logId}: Redux actions not available`);
|
||||
}
|
||||
|
||||
const conversation = window.ConversationController.get(conversationId);
|
||||
if (!conversation) {
|
||||
log.error(`${logId}: Could not find conversation, cannot start call`);
|
||||
this.stopCallingLobby();
|
||||
return;
|
||||
}
|
||||
|
||||
const remoteUserId = this.getRemoteUserIdFromConversation(conversation);
|
||||
if (!remoteUserId || !this.localDeviceId) {
|
||||
log.error(`${logId}: Missing identifier, new call not allowed.`);
|
||||
|
@ -1226,21 +1229,25 @@ export class CallingClass {
|
|||
return;
|
||||
}
|
||||
|
||||
const logId = `joinGroupCall(${getConversationIdForLogging(conversation)})`;
|
||||
log.info(logId);
|
||||
|
||||
if (
|
||||
!conversation.groupId ||
|
||||
!conversation.publicParams ||
|
||||
!conversation.secretParams
|
||||
) {
|
||||
log.error(
|
||||
'Conversation is missing required parameters. Cannot join group call'
|
||||
`${logId}: Conversation is missing required parameters. Cannot join group call`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const logId = `joinGroupCall(${getConversationIdForLogging(conversation)})`;
|
||||
const haveMediaPermissions = await this.requestPermissions(hasLocalVideo);
|
||||
if (!haveMediaPermissions) {
|
||||
log.info('Permissions were denied, but allow joining group call');
|
||||
log.info(
|
||||
`${logId}: Permissions were denied, but allow joining group call`
|
||||
);
|
||||
}
|
||||
|
||||
await this.startDeviceReselectionTimer();
|
||||
|
@ -1259,6 +1266,7 @@ export class CallingClass {
|
|||
groupCall.ringAll();
|
||||
}
|
||||
|
||||
log.info(`${logId}: Joining in RingRTC`);
|
||||
groupCall.join();
|
||||
}
|
||||
|
||||
|
@ -1553,9 +1561,14 @@ export class CallingClass {
|
|||
hasLocalAudio: boolean;
|
||||
hasLocalVideo: boolean;
|
||||
}): Promise<void> {
|
||||
const logId = `joinCallLinkCall(${roomId})`;
|
||||
log.info(logId);
|
||||
|
||||
const haveMediaPermissions = await this.requestPermissions(hasLocalVideo);
|
||||
if (!haveMediaPermissions) {
|
||||
log.info('Permissions were denied, but allow joining call link call');
|
||||
log.info(
|
||||
`${logId}: Permissions were denied, but allow joining call link call`
|
||||
);
|
||||
}
|
||||
|
||||
await this.startDeviceReselectionTimer();
|
||||
|
@ -1577,6 +1590,7 @@ export class CallingClass {
|
|||
groupCall.setOutgoingVideoMuted(!hasLocalVideo);
|
||||
drop(this.enableCaptureAndSend(groupCall));
|
||||
|
||||
log.info(`${logId}: Joining in RingRTC`);
|
||||
groupCall.join();
|
||||
}
|
||||
|
||||
|
|
|
@ -2342,8 +2342,14 @@ function startCall(
|
|||
payload: StartCallType
|
||||
): ThunkAction<void, RootStateType, unknown, StartDirectCallActionType> {
|
||||
return async (dispatch, getState) => {
|
||||
const { conversationId, hasLocalAudio, hasLocalVideo } = payload;
|
||||
switch (payload.callMode) {
|
||||
const { callMode, conversationId, hasLocalAudio, hasLocalVideo } = payload;
|
||||
|
||||
const state = getState();
|
||||
const { activeCallState } = state.calling;
|
||||
|
||||
log.info(`startCall for conversation ${conversationId}, mode ${callMode}`);
|
||||
|
||||
switch (callMode) {
|
||||
case CallMode.Direct:
|
||||
await calling.startOutgoingDirectCall(
|
||||
conversationId,
|
||||
|
@ -2358,8 +2364,6 @@ function startCall(
|
|||
case CallMode.Group: {
|
||||
let outgoingRing: boolean;
|
||||
|
||||
const state = getState();
|
||||
const { activeCallState } = state.calling;
|
||||
if (activeCallState?.outgoingRing) {
|
||||
const conversation = getOwn(
|
||||
state.conversations.conversationLookup,
|
||||
|
@ -2383,8 +2387,6 @@ function startCall(
|
|||
break;
|
||||
}
|
||||
case CallMode.Adhoc: {
|
||||
const state = getState();
|
||||
|
||||
const callLink = getOwn(state.calling.callLinks, conversationId);
|
||||
if (!callLink) {
|
||||
log.error(
|
||||
|
@ -2406,7 +2408,7 @@ function startCall(
|
|||
break;
|
||||
}
|
||||
default:
|
||||
throw missingCaseError(payload.callMode);
|
||||
throw missingCaseError(callMode);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue