Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
Add participantRoleChanged event to external API (#6573)
Jim Bullingtonacbf641fb45c
diff --git a/conference.js b/conference.jsindex 2e50e68349..9665623b80 100644--- a/conference.js+++ b/conference.js@@ -2093,6 +2093,7 @@ export default {logger.info(`My role changed, new role: ${role}`);APP.store.dispatch(localParticipantRoleChanged(role));+ APP.API.notifyUserRoleChanged(id, role);} else {APP.store.dispatch(participantRoleChanged(id, role));}diff --git a/doc/api.md b/doc/api.mdindex 9281c3a6e3..85b1e8d607 100644--- a/doc/api.md+++ b/doc/api.md@@ -465,6 +465,14 @@ changes. The listener will receive an object with the following structure:}```+* **participantRoleChanged** - event notification fired when the role of the local user has changed (none, moderator, participant). The listener will receive an object with the following structure:+```javascript+{+ id: string // the id of the participant+ role: string // the new role of the participant+}+```+* **passwordRequired** - event notifications fired when failing to join a room because it has a password.* **videoConferenceJoined** - event notifications fired when the local user has joined the video conference. The listener will receive an object with the following structure:diff --git a/modules/API/API.js b/modules/API/API.jsindex a37199b3cc..7adec2f62a 100644--- a/modules/API/API.js+++ b/modules/API/API.js@@ -439,6 +439,22 @@ class API {});}+ /**+ * Notify external application (if API is enabled) that the user role+ * has changed.+ *+ * @param {string} id - User id.+ * @param {string} role - The new user role.+ * @returns {void}+ */+ notifyUserRoleChanged(id: string, role: string) {+ this._sendEvent({+ name: 'participant-role-changed',+ id,+ role+ });+ }+/*** Notify external application (if API is enabled) that user changed their* avatar.diff --git a/modules/API/external/external_api.js b/modules/API/external/external_api.jsindex c0d3a8cdb9..a79faf3bb6 100644--- a/modules/API/external/external_api.js+++ b/modules/API/external/external_api.js@@ -67,6 +67,7 @@ const events = {'participant-joined': 'participantJoined','participant-kicked-out': 'participantKickedOut','participant-left': 'participantLeft',+ 'participant-role-changed': 'participantRoleChanged','password-required': 'passwordRequired','proxy-connection-event': 'proxyConnectionEvent','video-ready-to-close': 'readyToClose',diff --git a/react/features/base/participants/actionTypes.js b/react/features/base/participants/actionTypes.jsindex 6bfb3cc287..377a45b5e1 100644--- a/react/features/base/participants/actionTypes.js+++ b/react/features/base/participants/actionTypes.js@@ -57,6 +57,19 @@ export const PARTICIPANT_DISPLAY_NAME_CHANGED*/export const PARTICIPANT_ID_CHANGED = 'PARTICIPANT_ID_CHANGED';+/**+ * Action to signal that participant role has changed. e.+ *+ * {+ * type: PARTICIPANT_ROLE_CHANGED,+ * participant: {+ * id: string+ * }+ * role: string+ * }+ */+export const PARTICIPANT_ROLE_CHANGED = 'PARTICIPANT_ROLE_CHANGED';+/*** Action to signal that a participant has joined.*diff --git a/react/features/external-api/middleware.js b/react/features/external-api/middleware.jsindex 1ac2b28c42..a9d41ea4bc 100644--- a/react/features/external-api/middleware.js+++ b/react/features/external-api/middleware.js@@ -12,6 +12,7 @@ import {PARTICIPANT_KICKED,PARTICIPANT_LEFT,PARTICIPANT_JOINED,+ PARTICIPANT_ROLE_CHANGED,SET_LOADABLE_AVATAR_URL,getLocalParticipant,getParticipantById@@ -157,6 +158,10 @@ MiddlewareRegistry.register(store => next => action => {break;}+ case PARTICIPANT_ROLE_CHANGED:+ APP.API.notifyUserRoleChanged(action.participant.id, action.participant.role);+ break;+case SET_FILMSTRIP_VISIBLE:APP.API.notifyFilmstripDisplayChanged(action.visible);break;