Basic discard of old call events

This commit is contained in:
Valere 2020-06-17 15:23:03 +02:00
parent 843da1d48d
commit c85ba51274
2 changed files with 8 additions and 1 deletions

View File

@ -52,10 +52,17 @@ internal class DefaultCallEventsObserverTask @Inject constructor(
}
private fun update(realm: Realm, events: List<Event>, userId: String) {
val now = System.currentTimeMillis()
events.forEach { event ->
event.roomId ?: return@forEach Unit.also {
Timber.w("Event with no room id ${event.eventId}")
}
val age = now - (event.ageLocalTs ?: now)
if (age > 40_000) {
// To old to ring?
return@forEach
}
event.ageLocalTs
decryptIfNeeded(event)
if (EventType.isCallEvent(event.getClearType())) {
callService.onCallEvent(event)

View File

@ -581,7 +581,7 @@ class WebRtcPeerConnectionManager @Inject constructor(
override fun onCallInviteReceived(mxCall: MxCall, callInviteContent: CallInviteContent) {
Timber.v("## VOIP onCallInviteReceived callId ${mxCall.callId}")
// TODO What if a call is currently active?
// to simplify we only treat one call at a time, and ignore others
if (currentCall != null) {
Timber.w("## VOIP receiving incoming call while already in call?")
// Just ignore, maybe we could answer from other session?