From 0f08c00c07b9495dd9b8b11f6bc2a8cd0ca105e9 Mon Sep 17 00:00:00 2001 From: Timo <16718859+toger5@users.noreply.github.com> Date: Thu, 25 Jul 2024 12:57:27 +0200 Subject: [PATCH] Be specific about what is considered a MSC4143 call member event. (#4328) * Be specific about what is considered a MSC4143 call member event. * review * check for empty event first * Optimize for new session type events If its a session type event we do not want to run two "key in" checks. We expect legacy events to be the less comment type going forward. * awkward but necessary key count optimization --- src/matrixrtc/MatrixRTCSession.ts | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/matrixrtc/MatrixRTCSession.ts b/src/matrixrtc/MatrixRTCSession.ts index cc155fd3e6a..7f6d12aa203 100644 --- a/src/matrixrtc/MatrixRTCSession.ts +++ b/src/matrixrtc/MatrixRTCSession.ts @@ -160,26 +160,27 @@ export class MatrixRTCSession extends TypedEventEmitter 1 && "focus_active" in content) { + // We have a MSC4143 event membership event + membershipContents.push(content); + } else if (eventKeysCount === 1 && "memberships" in content) { // we have a legacy (one event for all devices) event if (!Array.isArray(content["memberships"])) { logger.warn(`Malformed member event from ${memberEvent.getSender()}: memberships is not an array`); continue; } membershipContents = content["memberships"]; - } else { - // We have a MSC4143 event membership event - if (Object.keys(content).length !== 0) { - // We checked for empty content to not try to construct CallMembership's with {}. - membershipContents.push(content); - } - } - if (membershipContents.length === 0) { - continue; } + if (membershipContents.length === 0) continue; + for (const membershipData of membershipContents) { try { const membership = new CallMembership(memberEvent, membershipData);