瀏覽代碼

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
 api.executeCommand('displayName', 'New Nickname');
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
 * **subject** - Sets the subject of the conference. This command requires one argument - the new subject to be set.
200
 * **subject** - Sets the subject of the conference. This command requires one argument - the new subject to be set.
196
 ```javascript
201
 ```javascript
197
 api.executeCommand('subject', 'New Conference Subject');
202
 api.executeCommand('subject', 'New Conference Subject');
389
 }
394
 }
390
 ```
395
 ```
391
 
396
 
397
+* **passwordRequired** - event notifications fired when failing to join a room because it has a password.
398
+
392
 * **videoConferenceJoined** - event notifications fired when the local user has joined the video conference. The listener will receive an object with the following structure:
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
 ```javascript
400
 ```javascript
394
 {
401
 {

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

5
     createApiEvent,
5
     createApiEvent,
6
     sendAnalytics
6
     sendAnalytics
7
 } from '../../react/features/analytics';
7
 } from '../../react/features/analytics';
8
-import { setSubject } from '../../react/features/base/conference';
8
+import { setPassword, setSubject } from '../../react/features/base/conference';
9
 import { parseJWTFromURLParams } from '../../react/features/base/jwt';
9
 import { parseJWTFromURLParams } from '../../react/features/base/jwt';
10
 import { invite } from '../../react/features/invite';
10
 import { invite } from '../../react/features/invite';
11
 import { toggleTileView } from '../../react/features/video-layout';
11
 import { toggleTileView } from '../../react/features/video-layout';
65
             sendAnalytics(createApiEvent('display.name.changed'));
65
             sendAnalytics(createApiEvent('display.name.changed'));
66
             APP.conference.changeLocalDisplayName(displayName);
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
         'proxy-connection-event': event => {
90
         'proxy-connection-event': event => {
69
             APP.conference.onProxyConnectionEvent(event);
91
             APP.conference.onProxyConnectionEvent(event);
70
         },
92
         },
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
      * Notify external application (if API is enabled) that the screen sharing
663
      * Notify external application (if API is enabled) that the screen sharing
632
      * has been turned on/off.
664
      * has been turned on/off.

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

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

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

1
 // @flow
1
 // @flow
2
 
2
 
3
+import { CONFERENCE_FAILED } from '../base/conference';
3
 import { NOTIFY_CAMERA_ERROR, NOTIFY_MIC_ERROR } from '../base/devices';
4
 import { NOTIFY_CAMERA_ERROR, NOTIFY_MIC_ERROR } from '../base/devices';
5
+import { JitsiConferenceErrors } from '../base/lib-jitsi-meet';
4
 import { MiddlewareRegistry } from '../base/redux';
6
 import { MiddlewareRegistry } from '../base/redux';
5
 
7
 
6
 declare var APP: Object;
8
 declare var APP: Object;
12
  */
14
  */
13
 MiddlewareRegistry.register((/* store */) => next => action => {
15
 MiddlewareRegistry.register((/* store */) => next => action => {
14
     switch (action.type) {
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
     case NOTIFY_CAMERA_ERROR:
25
     case NOTIFY_CAMERA_ERROR:
16
         if (action.error) {
26
         if (action.error) {
17
             APP.API.notifyOnCameraError(
27
             APP.API.notifyOnCameraError(

Loading…
取消
儲存