From 21af9b5c1bc0573fd435c197de29420bc2259ec7 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Mon, 4 Jul 2022 10:30:59 +1000 Subject: [PATCH] fix: show call missed message on call too old received --- ts/session/utils/calling/CallManager.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ts/session/utils/calling/CallManager.ts b/ts/session/utils/calling/CallManager.ts index f8c4819f5..a0c3c02f3 100644 --- a/ts/session/utils/calling/CallManager.ts +++ b/ts/session/utils/calling/CallManager.ts @@ -1043,6 +1043,7 @@ export async function handleCallTypeOffer( window.log.info('handling callMessage OFFER with uuid: ', remoteCallUUID); if (!getCallMediaPermissionsSettings()) { + // we still add it to the cache so if user toggles settings in the next 60 sec, he can still reply to it const cachedMsg = getCachedMessageFromCallMessage(callMessage, incomingOfferTimestamp); pushCallMessageToCallCache(sender, remoteCallUUID, cachedMsg); @@ -1059,6 +1060,12 @@ export async function handleCallTypeOffer( return; } + // if the offer is more than the call timeout, don't try to handle it (as the sender would have already closed it) + if (incomingOfferTimestamp <= Date.now() - callTimeoutMs) { + await handleMissedCall(sender, incomingOfferTimestamp, 'too-old-timestamp'); + return; + } + if (currentCallUUID && currentCallUUID !== remoteCallUUID) { // we just got a new offer with a different callUUID. this is a missed call (from either the same sender or another one) if (callCache.get(sender)?.has(currentCallUUID)) { @@ -1124,7 +1131,7 @@ export async function handleCallTypeOffer( export async function handleMissedCall( sender: string, incomingOfferTimestamp: number, - reason: 'not-approved' | 'permissions' | 'another-call-ongoing' + reason: 'not-approved' | 'permissions' | 'another-call-ongoing' | 'too-old-timestamp' ) { const incomingCallConversation = getConversationController().get(sender); @@ -1143,6 +1150,9 @@ export async function handleMissedCall( case 'not-approved': ToastUtils.pushedMissedCallNotApproved(displayname); break; + case 'too-old-timestamp': + //no toast for this case, the missed call notification is enough + break; default: }