From 00250e535c4a47b9c3a231229fc961bebdb74ccf Mon Sep 17 00:00:00 2001 From: Jamie Kyle <113370520+jamiebuilds-signal@users.noreply.github.com> Date: Thu, 29 Jun 2023 11:39:21 -0700 Subject: [PATCH] Ensure call history is added when call is accepted --- ts/services/calling.ts | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/ts/services/calling.ts b/ts/services/calling.ts index 67d1d0362ceb..1ebdc1e08762 100644 --- a/ts/services/calling.ts +++ b/ts/services/calling.ts @@ -1949,6 +1949,11 @@ export class CallingClass { call.handleStateChanged = async () => { if (call.state === CallState.Accepted) { acceptedTime = acceptedTime || Date.now(); + await this.addCallHistoryForAcceptedCall( + conversation, + call, + acceptedTime + ); } else if (call.state === CallState.Ended) { try { await this.addCallHistoryForEndedCall( @@ -2128,6 +2133,34 @@ export class CallingClass { return true; } + private async addCallHistoryForAcceptedCall( + conversation: ConversationModel, + call: Call, + acceptedTime: number + ) { + const callId = Long.fromValue(call.callId).toString(); + try { + log.info('addCallHistoryForAcceptedCall: Adding call history'); + await conversation.addCallHistory( + { + callId, + callMode: CallMode.Direct, + wasIncoming: call.isIncoming, + wasVideoCall: call.isVideoCall, + wasDeclined: false, + acceptedTime, + endedTime: undefined, + }, + undefined + ); + } catch (error) { + log.error( + 'addCallHistoryForAcceptedCall: Failed to add call history', + Errors.toLogFormat(error) + ); + } + } + private async addCallHistoryForEndedCall( conversation: ConversationModel, call: Call,