Browse Source

feat(external_api) set and cancel private chat through external API

- allow managing chat through API when chat button is not present on UI
master
hmuresan 4 years ago
parent
commit
0a5910f0b3
3 changed files with 25 additions and 6 deletions
  1. 20
    1
      modules/API/API.js
  2. 2
    0
      modules/API/external/external_api.js
  3. 3
    5
      react/features/chat/middleware.js

+ 20
- 1
modules/API/API.js View File

14
 } from '../../react/features/base/conference';
14
 } from '../../react/features/base/conference';
15
 import { parseJWTFromURLParams } from '../../react/features/base/jwt';
15
 import { parseJWTFromURLParams } from '../../react/features/base/jwt';
16
 import JitsiMeetJS, { JitsiRecordingConstants } from '../../react/features/base/lib-jitsi-meet';
16
 import JitsiMeetJS, { JitsiRecordingConstants } from '../../react/features/base/lib-jitsi-meet';
17
-import { pinParticipant } from '../../react/features/base/participants';
17
+import { pinParticipant, getParticipantById } from '../../react/features/base/participants';
18
+import { setPrivateMessageRecipient } from '../../react/features/chat/actions';
18
 import {
19
 import {
19
     processExternalDeviceRequest
20
     processExternalDeviceRequest
20
 } from '../../react/features/device-selection/functions';
21
 } from '../../react/features/device-selection/functions';
330
             } else {
331
             } else {
331
                 logger.error('No recording or streaming session found');
332
                 logger.error('No recording or streaming session found');
332
             }
333
             }
334
+        },
335
+        'initiate-private-chat': participantId => {
336
+            const state = APP.store.getState();
337
+            const participant = getParticipantById(state, participantId);
338
+
339
+            if (participant) {
340
+                const { isOpen: isChatOpen } = state['features/chat'];
341
+
342
+                if (!isChatOpen) {
343
+                    APP.UI.toggleChat();
344
+                }
345
+                APP.store.dispatch(setPrivateMessageRecipient(participant));
346
+            } else {
347
+                logger.error('No participant found for the given participantId');
348
+            }
349
+        },
350
+        'cancel-private-chat': () => {
351
+            APP.store.dispatch(setPrivateMessageRecipient());
333
         }
352
         }
334
     };
353
     };
335
     transport.on('event', ({ data, name }) => {
354
     transport.on('event', ({ data, name }) => {

+ 2
- 0
modules/API/external/external_api.js View File

28
  */
28
  */
29
 const commands = {
29
 const commands = {
30
     avatarUrl: 'avatar-url',
30
     avatarUrl: 'avatar-url',
31
+    cancelPrivateChat: 'cancel-private-chat',
31
     displayName: 'display-name',
32
     displayName: 'display-name',
32
     e2eeKey: 'e2ee-key',
33
     e2eeKey: 'e2ee-key',
33
     email: 'email',
34
     email: 'email',
34
     toggleLobby: 'toggle-lobby',
35
     toggleLobby: 'toggle-lobby',
35
     hangup: 'video-hangup',
36
     hangup: 'video-hangup',
37
+    intiatePrivateChat: 'initiate-private-chat',
36
     muteEveryone: 'mute-everyone',
38
     muteEveryone: 'mute-everyone',
37
     password: 'password',
39
     password: 'password',
38
     pinParticipant: 'pin-participant',
40
     pinParticipant: 'pin-participant',

+ 3
- 5
react/features/chat/middleware.js View File

19
 import { MiddlewareRegistry, StateListenerRegistry } from '../base/redux';
19
 import { MiddlewareRegistry, StateListenerRegistry } from '../base/redux';
20
 import { playSound, registerSound, unregisterSound } from '../base/sounds';
20
 import { playSound, registerSound, unregisterSound } from '../base/sounds';
21
 import { showToolbox } from '../toolbox/actions';
21
 import { showToolbox } from '../toolbox/actions';
22
-import { isButtonEnabled } from '../toolbox/functions';
23
 
22
 
24
 import { SEND_MESSAGE, SET_PRIVATE_MESSAGE_RECIPIENT } from './actionTypes';
23
 import { SEND_MESSAGE, SET_PRIVATE_MESSAGE_RECIPIENT } from './actionTypes';
25
 import { addMessage, clearMessages, toggleChat } from './actions';
24
 import { addMessage, clearMessages, toggleChat } from './actions';
152
  * @returns {void}
151
  * @returns {void}
153
  */
152
  */
154
 function _addChatMsgListener(conference, store) {
153
 function _addChatMsgListener(conference, store) {
155
-    if ((typeof APP !== 'undefined' && !isButtonEnabled('chat'))
156
-        || store.getState()['features/base/config'].iAmRecorder) {
157
-        // We don't register anything on web if the chat button is not enabled in interfaceConfig
158
-        // or we are in iAmRecorder mode
154
+
155
+    if (store.getState()['features/base/config'].iAmRecorder) {
156
+        // We don't register anything on web if we are in iAmRecorder mode
159
         return;
157
         return;
160
     }
158
     }
161
 
159
 

Loading…
Cancel
Save