Pārlūkot izejas kodu

Add participantRoleChanged event to external API (#6573)

* Add participantRoleChanged event to external API

* Update API documentation

* Remove unneeded whitespace

* Remove more unneeded whitespace

* Fix jsdoc formatting

* Fix jsdoc formatting
master
Jim Bullington 5 gadus atpakaļ
vecāks
revīzija
acbf641fb4
Revīzijas autora e-pasta adrese nav piesaistīta nevienam kontam

+ 1
- 0
conference.js Parādīt failu

@@ -2093,6 +2093,7 @@ export default {
2093 2093
                 logger.info(`My role changed, new role: ${role}`);
2094 2094
 
2095 2095
                 APP.store.dispatch(localParticipantRoleChanged(role));
2096
+                APP.API.notifyUserRoleChanged(id, role);
2096 2097
             } else {
2097 2098
                 APP.store.dispatch(participantRoleChanged(id, role));
2098 2099
             }

+ 8
- 0
doc/api.md Parādīt failu

@@ -465,6 +465,14 @@ changes. The listener will receive an object with the following structure:
465 465
 }
466 466
 ```
467 467
 
468
+* **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:
469
+```javascript
470
+{
471
+    id: string // the id of the participant
472
+    role: string // the new role of the participant
473
+}
474
+```
475
+
468 476
 * **passwordRequired** - event notifications fired when failing to join a room because it has a password.
469 477
 
470 478
 * **videoConferenceJoined** - event notifications fired when the local user has joined the video conference. The listener will receive an object with the following structure:

+ 16
- 0
modules/API/API.js Parādīt failu

@@ -439,6 +439,22 @@ class API {
439 439
         });
440 440
     }
441 441
 
442
+    /**
443
+     * Notify external application (if API is enabled) that the user role
444
+     * has changed.
445
+     *
446
+     * @param {string} id - User id.
447
+     * @param {string} role - The new user role.
448
+     * @returns {void}
449
+     */
450
+    notifyUserRoleChanged(id: string, role: string) {
451
+        this._sendEvent({
452
+            name: 'participant-role-changed',
453
+            id,
454
+            role
455
+        });
456
+    }
457
+
442 458
     /**
443 459
      * Notify external application (if API is enabled) that user changed their
444 460
      * avatar.

+ 1
- 0
modules/API/external/external_api.js Parādīt failu

@@ -67,6 +67,7 @@ const events = {
67 67
     'participant-joined': 'participantJoined',
68 68
     'participant-kicked-out': 'participantKickedOut',
69 69
     'participant-left': 'participantLeft',
70
+    'participant-role-changed': 'participantRoleChanged',
70 71
     'password-required': 'passwordRequired',
71 72
     'proxy-connection-event': 'proxyConnectionEvent',
72 73
     'video-ready-to-close': 'readyToClose',

+ 13
- 0
react/features/base/participants/actionTypes.js Parādīt failu

@@ -57,6 +57,19 @@ export const PARTICIPANT_DISPLAY_NAME_CHANGED
57 57
  */
58 58
 export const PARTICIPANT_ID_CHANGED = 'PARTICIPANT_ID_CHANGED';
59 59
 
60
+/**
61
+ * Action to signal that participant role has changed. e.
62
+ *
63
+ * {
64
+ *     type: PARTICIPANT_ROLE_CHANGED,
65
+ *     participant: {
66
+ *         id: string
67
+ *     }
68
+ *     role: string
69
+ * }
70
+ */
71
+export const PARTICIPANT_ROLE_CHANGED = 'PARTICIPANT_ROLE_CHANGED';
72
+
60 73
 /**
61 74
  * Action to signal that a participant has joined.
62 75
  *

+ 5
- 0
react/features/external-api/middleware.js Parādīt failu

@@ -12,6 +12,7 @@ import {
12 12
     PARTICIPANT_KICKED,
13 13
     PARTICIPANT_LEFT,
14 14
     PARTICIPANT_JOINED,
15
+    PARTICIPANT_ROLE_CHANGED,
15 16
     SET_LOADABLE_AVATAR_URL,
16 17
     getLocalParticipant,
17 18
     getParticipantById
@@ -157,6 +158,10 @@ MiddlewareRegistry.register(store => next => action => {
157 158
         break;
158 159
     }
159 160
 
161
+    case PARTICIPANT_ROLE_CHANGED:
162
+        APP.API.notifyUserRoleChanged(action.participant.id, action.participant.role);
163
+        break;
164
+
160 165
     case SET_FILMSTRIP_VISIBLE:
161 166
         APP.API.notifyFilmstripDisplayChanged(action.visible);
162 167
         break;

Notiek ielāde…
Atcelt
Saglabāt