diff --git a/conference.js b/conference.js index 5fe57778f..45a8728ce 100644 --- a/conference.js +++ b/conference.js @@ -1955,7 +1955,8 @@ export default { } ); - APP.UI.addListener(UIEvents.EMAIL_CHANGED, this.changeLocalEmail); + APP.UI.addListener(UIEvents.EMAIL_CHANGED, + this.changeLocalEmail.bind(this)); room.addCommandListener(this.commands.defaults.EMAIL, (data, from) => { APP.store.dispatch(participantUpdated({ conference: room, @@ -2537,7 +2538,9 @@ export default { APP.store.dispatch(updateSettings({ email: formattedEmail })); - + APP.API.notifyEmailChanged(localId, { + email: formattedEmail + }); sendData(commands.EMAIL, formattedEmail); }, diff --git a/doc/api.md b/doc/api.md index 9fa82e448..4fab09a5c 100644 --- a/doc/api.md +++ b/doc/api.md @@ -194,6 +194,15 @@ changes. The listener will receive an object with the following structure: } ``` +* **emailChange** - event notifications about email +changes. The listener will receive an object with the following structure: +```javascript +{ +"id": id, // the id of the participant that changed his email +"email": email // the new email +} +``` + * **participantJoined** - event notifications about new participants who join the room. The listener will receive an object with the following structure: ```javascript { @@ -290,6 +299,11 @@ You can get the display name of a participant in the conference with the followi var displayName = api.getDisplayName(participantId); ``` +You can get the email of a participant in the conference with the following API function: +```javascript +var email = api.getEmail(participantId); +``` + You can get the iframe HTML element where Jitsi Meet is loaded with the following API function: ```javascript var iframe = api.getIFrame(); diff --git a/modules/API/API.js b/modules/API/API.js index 7ad6daba5..01b438af1 100644 --- a/modules/API/API.js +++ b/modules/API/API.js @@ -363,6 +363,24 @@ class API { }); } + /** + * Notify external application (if API is enabled) that user changed their + * email. + * + * @param {string} id - User id. + * @param {string} email - The new email of the participant. + * @returns {void} + */ + notifyEmailChanged( + id: string, + { email }: Object) { + this._sendEvent({ + name: 'email-change', + email, + id + }); + } + /** * Notify external application (if API is enabled) that the conference has * been joined. diff --git a/modules/API/external/external_api.js b/modules/API/external/external_api.js index 870d4da31..69fe24daf 100644 --- a/modules/API/external/external_api.js +++ b/modules/API/external/external_api.js @@ -40,6 +40,7 @@ const events = { 'audio-availability-changed': 'audioAvailabilityChanged', 'audio-mute-status-changed': 'audioMuteStatusChanged', 'display-name-change': 'displayNameChange', + 'email-change': 'emailChange', 'feedback-submitted': 'feedbackSubmitted', 'incoming-message': 'incomingMessage', 'outgoing-message': 'outgoingMessage', @@ -398,6 +399,14 @@ export default class JitsiMeetExternalAPI extends EventEmitter { } break; } + case 'email-change': { + const user = this._participants[userID]; + + if (user) { + user.email = data.email; + } + break; + } case 'avatar-changed': { const user = this._participants[userID]; @@ -633,6 +642,18 @@ export default class JitsiMeetExternalAPI extends EventEmitter { return displayName; } + /** + * Returns the email of a participant. + * + * @param {string} participantId - The id of the participant. + * @returns {string} The email. + */ + getEmail(participantId) { + const { email } = this._participants[participantId] || {}; + + return email; + } + /** * Returns the formatted display name of a participant. *