Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Neto committed Dec 10, 2024
1 parent ac5ec13 commit 1cdc172
Showing 1 changed file with 30 additions and 26 deletions.
56 changes: 30 additions & 26 deletions plugin/Meet/api.js.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,41 +171,45 @@ interfaceConfigOverwrite: {

let myUserID;

// Listen for when the local participant joins the conference
// Set a loading name initially
api.executeCommand('displayName', 'Loading...');

// Listen for when the local participant successfully joins the conference
api.addListener('videoConferenceJoined', (event) => {
console.log('videoConferenceJoined', event);
myUserID = event.id; // Save the local participant's ID
});

// Listen for participants joining the conference
api.addListener('participantJoined', (participant) => {
console.log('participantJoined', participant, myUserID);
// Check if the participant is the local participant
if (participant.id === myUserID) {
console.log('participantJoined will change');
let currentName = participant.displayName || "";

// Check if the display name looks like a phone number
const phonePattern = /^[0-9()\-\s]+$/;
if (phonePattern.test(currentName)) {
console.log('participantJoined will change confirmed');
// Remove all non-numeric characters
const numbers = currentName.replace(/\D/g, '');

// Format the phone number to ** ****-**XX
if (numbers.length >= 4) {
currentName = `** ****-**${numbers.slice(-2)}`;
// Get the current display name of the local participant
api.getParticipantsInfo().then((participants) => {
const localParticipant = participants.find(p => p.participantId === myUserID);
if (localParticipant) {
let currentName = localParticipant.displayName || "";

// Check if the display name looks like a phone number
const phonePattern = /^[0-9()\-\s]+$/;
if (phonePattern.test(currentName)) {
console.log('Updating display name for local participant');
// Remove all non-numeric characters
const numbers = currentName.replace(/\D/g, '');

// Format the phone number to ** ****-**XX
if (numbers.length >= 4) {
currentName = `** ****-**${numbers.slice(-2)}`;
} else {
currentName = '**';
}

// Update the display name for the local participant
api.executeCommand('displayName', currentName);
} else {
currentName = '**';
// Restore the original display name if not a phone number
console.log('Restoring original display name');
api.executeCommand('displayName', currentName);
}
}

// Set the new display name for the local participant
api.executeCommand('displayName', currentName);
}
});
});


<?php
if (!empty($rtmpLink) && !empty($_REQUEST['startLiveMeet'])) {
?>
Expand Down

0 comments on commit 1cdc172

Please sign in to comment.