Ensure call history is added when call is accepted
This commit is contained in:
parent
505175d2ea
commit
00250e535c
1 changed files with 33 additions and 0 deletions
|
@ -1949,6 +1949,11 @@ export class CallingClass {
|
||||||
call.handleStateChanged = async () => {
|
call.handleStateChanged = async () => {
|
||||||
if (call.state === CallState.Accepted) {
|
if (call.state === CallState.Accepted) {
|
||||||
acceptedTime = acceptedTime || Date.now();
|
acceptedTime = acceptedTime || Date.now();
|
||||||
|
await this.addCallHistoryForAcceptedCall(
|
||||||
|
conversation,
|
||||||
|
call,
|
||||||
|
acceptedTime
|
||||||
|
);
|
||||||
} else if (call.state === CallState.Ended) {
|
} else if (call.state === CallState.Ended) {
|
||||||
try {
|
try {
|
||||||
await this.addCallHistoryForEndedCall(
|
await this.addCallHistoryForEndedCall(
|
||||||
|
@ -2128,6 +2133,34 @@ export class CallingClass {
|
||||||
return true;
|
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(
|
private async addCallHistoryForEndedCall(
|
||||||
conversation: ConversationModel,
|
conversation: ConversationModel,
|
||||||
call: Call,
|
call: Call,
|
||||||
|
|
Loading…
Reference in a new issue