mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 18:35:40 +03:00
Basic discard of old call events
This commit is contained in:
parent
843da1d48d
commit
c85ba51274
2 changed files with 8 additions and 1 deletions
|
@ -52,10 +52,17 @@ internal class DefaultCallEventsObserverTask @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun update(realm: Realm, events: List<Event>, userId: String) {
|
private fun update(realm: Realm, events: List<Event>, userId: String) {
|
||||||
|
val now = System.currentTimeMillis()
|
||||||
events.forEach { event ->
|
events.forEach { event ->
|
||||||
event.roomId ?: return@forEach Unit.also {
|
event.roomId ?: return@forEach Unit.also {
|
||||||
Timber.w("Event with no room id ${event.eventId}")
|
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)
|
decryptIfNeeded(event)
|
||||||
if (EventType.isCallEvent(event.getClearType())) {
|
if (EventType.isCallEvent(event.getClearType())) {
|
||||||
callService.onCallEvent(event)
|
callService.onCallEvent(event)
|
||||||
|
|
|
@ -581,7 +581,7 @@ class WebRtcPeerConnectionManager @Inject constructor(
|
||||||
|
|
||||||
override fun onCallInviteReceived(mxCall: MxCall, callInviteContent: CallInviteContent) {
|
override fun onCallInviteReceived(mxCall: MxCall, callInviteContent: CallInviteContent) {
|
||||||
Timber.v("## VOIP onCallInviteReceived callId ${mxCall.callId}")
|
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) {
|
if (currentCall != null) {
|
||||||
Timber.w("## VOIP receiving incoming call while already in call?")
|
Timber.w("## VOIP receiving incoming call while already in call?")
|
||||||
// Just ignore, maybe we could answer from other session?
|
// Just ignore, maybe we could answer from other session?
|
||||||
|
|
Loading…
Reference in a new issue