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

- allow managing chat through API when chat button is not present on UI
pull/8384/head
hmuresan 4 years ago committed by Дамян Минков
parent b6f7f8fba7
commit 0a5910f0b3
  1. 21
      modules/API/API.js
  2. 2
      modules/API/external/external_api.js
  3. 8
      react/features/chat/middleware.js

@ -14,7 +14,8 @@ import {
} from '../../react/features/base/conference'; } from '../../react/features/base/conference';
import { parseJWTFromURLParams } from '../../react/features/base/jwt'; import { parseJWTFromURLParams } from '../../react/features/base/jwt';
import JitsiMeetJS, { JitsiRecordingConstants } from '../../react/features/base/lib-jitsi-meet'; import JitsiMeetJS, { JitsiRecordingConstants } from '../../react/features/base/lib-jitsi-meet';
import { pinParticipant } from '../../react/features/base/participants'; import { pinParticipant, getParticipantById } from '../../react/features/base/participants';
import { setPrivateMessageRecipient } from '../../react/features/chat/actions';
import { import {
processExternalDeviceRequest processExternalDeviceRequest
} from '../../react/features/device-selection/functions'; } from '../../react/features/device-selection/functions';
@ -330,6 +331,24 @@ function initCommands() {
} else { } else {
logger.error('No recording or streaming session found'); logger.error('No recording or streaming session found');
} }
},
'initiate-private-chat': participantId => {
const state = APP.store.getState();
const participant = getParticipantById(state, participantId);
if (participant) {
const { isOpen: isChatOpen } = state['features/chat'];
if (!isChatOpen) {
APP.UI.toggleChat();
}
APP.store.dispatch(setPrivateMessageRecipient(participant));
} else {
logger.error('No participant found for the given participantId');
}
},
'cancel-private-chat': () => {
APP.store.dispatch(setPrivateMessageRecipient());
} }
}; };
transport.on('event', ({ data, name }) => { transport.on('event', ({ data, name }) => {

@ -28,11 +28,13 @@ const ALWAYS_ON_TOP_FILENAMES = [
*/ */
const commands = { const commands = {
avatarUrl: 'avatar-url', avatarUrl: 'avatar-url',
cancelPrivateChat: 'cancel-private-chat',
displayName: 'display-name', displayName: 'display-name',
e2eeKey: 'e2ee-key', e2eeKey: 'e2ee-key',
email: 'email', email: 'email',
toggleLobby: 'toggle-lobby', toggleLobby: 'toggle-lobby',
hangup: 'video-hangup', hangup: 'video-hangup',
intiatePrivateChat: 'initiate-private-chat',
muteEveryone: 'mute-everyone', muteEveryone: 'mute-everyone',
password: 'password', password: 'password',
pinParticipant: 'pin-participant', pinParticipant: 'pin-participant',

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

Loading…
Cancel
Save