From 09ffa0940484862139c3fe431d4c3ef3392f2232 Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Tue, 18 Aug 2020 10:07:47 +0200 Subject: [PATCH] Ignore old webrtc invites --- lib/src/client.dart | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/lib/src/client.dart b/lib/src/client.dart index f234ac8..73f495a 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -983,15 +983,20 @@ class Client extends MatrixApi { final rawUnencryptedEvent = update.content; - if (rawUnencryptedEvent['type'] == EventTypes.CallInvite) { - onCallInvite.add(Event.fromJson(rawUnencryptedEvent, room, sortOrder)); - } else if (rawUnencryptedEvent['type'] == EventTypes.CallHangup) { - onCallHangup.add(Event.fromJson(rawUnencryptedEvent, room, sortOrder)); - } else if (rawUnencryptedEvent['type'] == EventTypes.CallAnswer) { - onCallAnswer.add(Event.fromJson(rawUnencryptedEvent, room, sortOrder)); - } else if (rawUnencryptedEvent['type'] == EventTypes.CallCandidates) { - onCallCandidates - .add(Event.fromJson(rawUnencryptedEvent, room, sortOrder)); + if (prevBatch != null && type == 'timeline') { + if (rawUnencryptedEvent['type'] == EventTypes.CallInvite) { + onCallInvite + .add(Event.fromJson(rawUnencryptedEvent, room, sortOrder)); + } else if (rawUnencryptedEvent['type'] == EventTypes.CallHangup) { + onCallHangup + .add(Event.fromJson(rawUnencryptedEvent, room, sortOrder)); + } else if (rawUnencryptedEvent['type'] == EventTypes.CallAnswer) { + onCallAnswer + .add(Event.fromJson(rawUnencryptedEvent, room, sortOrder)); + } else if (rawUnencryptedEvent['type'] == EventTypes.CallCandidates) { + onCallCandidates + .add(Event.fromJson(rawUnencryptedEvent, room, sortOrder)); + } } } }