浏览代码

feat(api): notify of password required

master
Leonard Kim 5 年前
父节点
当前提交
ae3b70eb13
共有 4 个文件被更改,包括 52 次插入1 次删除
  1. 7
    0
      doc/api.md
  2. 33
    1
      modules/API/API.js
  3. 2
    0
      modules/API/external/external_api.js
  4. 10
    0
      react/features/external-api/middleware.js

+ 7
- 0
doc/api.md 查看文件

@@ -192,6 +192,11 @@ The `command` parameter is String object with the name of the command. The follo
192 192
 api.executeCommand('displayName', 'New Nickname');
193 193
 ```
194 194
 
195
+* **password** - Sets the password for the room. This command requires one argument - the password name to be set.
196
+```javascript
197
+api.executeCommand('password', 'The Password');
198
+```
199
+
195 200
 * **subject** - Sets the subject of the conference. This command requires one argument - the new subject to be set.
196 201
 ```javascript
197 202
 api.executeCommand('subject', 'New Conference Subject');
@@ -389,6 +394,8 @@ changes. The listener will receive an object with the following structure:
389 394
 }
390 395
 ```
391 396
 
397
+* **passwordRequired** - event notifications fired when failing to join a room because it has a password.
398
+
392 399
 * **videoConferenceJoined** - event notifications fired when the local user has joined the video conference. The listener will receive an object with the following structure:
393 400
 ```javascript
394 401
 {

+ 33
- 1
modules/API/API.js 查看文件

@@ -5,7 +5,7 @@ import {
5 5
     createApiEvent,
6 6
     sendAnalytics
7 7
 } from '../../react/features/analytics';
8
-import { setSubject } from '../../react/features/base/conference';
8
+import { setPassword, setSubject } from '../../react/features/base/conference';
9 9
 import { parseJWTFromURLParams } from '../../react/features/base/jwt';
10 10
 import { invite } from '../../react/features/invite';
11 11
 import { toggleTileView } from '../../react/features/video-layout';
@@ -65,6 +65,28 @@ function initCommands() {
65 65
             sendAnalytics(createApiEvent('display.name.changed'));
66 66
             APP.conference.changeLocalDisplayName(displayName);
67 67
         },
68
+        'password': password => {
69
+            const { conference, passwordRequired }
70
+                = APP.store.getState()['features/base/conference'];
71
+
72
+            if (passwordRequired) {
73
+                sendAnalytics(createApiEvent('submit.password'));
74
+
75
+                APP.store.dispatch(setPassword(
76
+                    passwordRequired,
77
+                    passwordRequired.join,
78
+                    password
79
+                ));
80
+            } else {
81
+                sendAnalytics(createApiEvent('password.changed'));
82
+
83
+                APP.store.dispatch(setPassword(
84
+                    conference,
85
+                    conference.lock,
86
+                    password
87
+                ));
88
+            }
89
+        },
68 90
         'proxy-connection-event': event => {
69 91
             APP.conference.onProxyConnectionEvent(event);
70 92
         },
@@ -627,6 +649,16 @@ class API {
627 649
         });
628 650
     }
629 651
 
652
+    /**
653
+     * Notify external application of the current meeting requiring a password
654
+     * to join.
655
+     *
656
+     * @returns {void}
657
+     */
658
+    notifyOnPasswordRequired() {
659
+        this._sendEvent({ name: 'password-required' });
660
+    }
661
+
630 662
     /**
631 663
      * Notify external application (if API is enabled) that the screen sharing
632 664
      * has been turned on/off.

+ 2
- 0
modules/API/external/external_api.js 查看文件

@@ -33,6 +33,7 @@ const commands = {
33 33
     displayName: 'display-name',
34 34
     email: 'email',
35 35
     hangup: 'video-hangup',
36
+    password: 'password',
36 37
     subject: 'subject',
37 38
     submitFeedback: 'submit-feedback',
38 39
     toggleAudio: 'toggle-audio',
@@ -63,6 +64,7 @@ const events = {
63 64
     'outgoing-message': 'outgoingMessage',
64 65
     'participant-joined': 'participantJoined',
65 66
     'participant-left': 'participantLeft',
67
+    'password-required': 'passwordRequired',
66 68
     'proxy-connection-event': 'proxyConnectionEvent',
67 69
     'video-ready-to-close': 'readyToClose',
68 70
     'video-conference-joined': 'videoConferenceJoined',

+ 10
- 0
react/features/external-api/middleware.js 查看文件

@@ -1,6 +1,8 @@
1 1
 // @flow
2 2
 
3
+import { CONFERENCE_FAILED } from '../base/conference';
3 4
 import { NOTIFY_CAMERA_ERROR, NOTIFY_MIC_ERROR } from '../base/devices';
5
+import { JitsiConferenceErrors } from '../base/lib-jitsi-meet';
4 6
 import { MiddlewareRegistry } from '../base/redux';
5 7
 
6 8
 declare var APP: Object;
@@ -12,6 +14,14 @@ declare var APP: Object;
12 14
  */
13 15
 MiddlewareRegistry.register((/* store */) => next => action => {
14 16
     switch (action.type) {
17
+    case CONFERENCE_FAILED: {
18
+        if (action.conference
19
+            && action.error.name === JitsiConferenceErrors.PASSWORD_REQUIRED) {
20
+            APP.API.notifyOnPasswordRequired();
21
+        }
22
+        break;
23
+    }
24
+
15 25
     case NOTIFY_CAMERA_ERROR:
16 26
         if (action.error) {
17 27
             APP.API.notifyOnCameraError(

正在加载...
取消
保存