From 024f30aa3aa30c631061ca9957052776b6fbaf0f Mon Sep 17 00:00:00 2001 From: automated-signal <37887102+automated-signal@users.noreply.github.com> Date: Fri, 13 Sep 2024 18:11:05 -0500 Subject: [PATCH] services/calling: Make logging consistent in startCall functions Co-authored-by: Scott Nonnenberg --- ts/services/calling.ts | 38 ++++++++++++++++++++++++++------------ ts/state/ducks/calling.ts | 16 +++++++++------- 2 files changed, 35 insertions(+), 19 deletions(-) diff --git a/ts/services/calling.ts b/ts/services/calling.ts index 122cdb9172ed..51ec20b408f9 100644 --- a/ts/services/calling.ts +++ b/ts/services/calling.ts @@ -881,20 +881,23 @@ export class CallingClass { hasLocalAudio: boolean, hasLocalVideo: boolean ): Promise { - 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 { + 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(); } diff --git a/ts/state/ducks/calling.ts b/ts/state/ducks/calling.ts index f127404915e9..fbeba763213a 100644 --- a/ts/state/ducks/calling.ts +++ b/ts/state/ducks/calling.ts @@ -2342,8 +2342,14 @@ function startCall( payload: StartCallType ): ThunkAction { 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); } }; }