Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(metadata): Keeps track of participants last used display name. #546

Merged
merged 2 commits into from
Sep 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions src/main/kotlin/org/jitsi/jibri/selenium/pageobjects/CallPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand All @@ -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) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skip if display name is undefined or 0 length.

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;
Expand Down Expand Up @@ -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;
}
Expand Down
Loading