Ensure call history is added when call is accepted

This commit is contained in:
Jamie Kyle 2023-06-29 11:39:21 -07:00 committed by GitHub
parent 505175d2ea
commit 00250e535c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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,