From 744975d3c5c5b3fa24ee834e63ec3194adfc8958 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BC=D1=8F=D0=BD=20=D0=9C=D0=B8=D0=BD=D0=BA?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Tue, 17 Sep 2024 13:29:42 -0500 Subject: [PATCH] feat(metadata): Keeps track of participants last used display name. (#546) * feat(metadata): Keeps track of participants last used display name. * squash: Fixes comments. --- .../jibri/selenium/pageobjects/CallPage.kt | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/org/jitsi/jibri/selenium/pageobjects/CallPage.kt b/src/main/kotlin/org/jitsi/jibri/selenium/pageobjects/CallPage.kt index c5756a19..c09209fa 100644 --- a/src/main/kotlin/org/jitsi/jibri/selenium/pageobjects/CallPage.kt +++ b/src/main/kotlin/org/jitsi/jibri/selenium/pageobjects/CallPage.kt @@ -123,15 +123,19 @@ class CallPage(driver: RemoteWebDriver) : AbstractPageObject(driver) { val result = driver.executeScript( """ try { - window._jibriParticipants = []; + window._jibriParticipants = new Map(); const existingMembers = APP.conference._room.room.members || {}; const existingMemberJids = Object.keys(existingMembers); console.log("There were " + existingMemberJids.length + " existing members"); existingMemberJids.forEach(jid => { const existingMember = existingMembers[jid]; + const nick = existingMember.nick; if (existingMember.identity) { console.log("Member ", existingMember, " has identity, adding"); - window._jibriParticipants.push(existingMember.identity); + if (nick && nick.length > 0 && existingMember.identity.user) { + existingMember.identity.user.name = nick; + } + window._jibriParticipants.set(jid, existingMember.identity); } else { console.log("Member ", existingMember.jid, " has no identity, skipping"); } @@ -141,10 +145,23 @@ class CallPage(driver: RemoteWebDriver) : AbstractPageObject(driver) { (from, nick, role, hidden, statsid, status, identity) => { console.log("Jibri got MUC_MEMBER_JOINED: ", from, identity); if (!hidden && identity) { - window._jibriParticipants.push(identity); + if (nick && nick.length > 0 && identity.user) { + identity.user.name = nick; + } + window._jibriParticipants.set(from, identity); + } + } + ); + APP.conference._room.room.addListener( + "xmpp.display_name_changed", + (jid, displayName) => { + const identity = window._jibriParticipants.get(jid); + if (displayName && displayName.length > 0 && identity && identity.user) { + identity.user.name = displayName; } } ); + return true; } catch (e) { return e.message; @@ -189,7 +206,7 @@ class CallPage(driver: RemoteWebDriver) : AbstractPageObject(driver) { val result = driver.executeScript( """ try { - return window._jibriParticipants; + return window._jibriParticipants.values().toArray(); } catch (e) { return e.message; }