Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

feat(external-api): Add send chat message command

hmuresan1d45edbb27a2
diff --git a/modules/API/API.js b/modules/API/API.js
index 0bef981e5e..1535bee745 100644
--- a/modules/API/API.js
+++ b/modules/API/API.js
@@ -27,6 +27,7 @@ import {
import { updateSettings } from '../../react/features/base/settings';
import { isToggleCameraEnabled, toggleCamera } from '../../react/features/base/tracks';
import {
+ sendMessage,
setPrivateMessageRecipient,
toggleChat
} from '../../react/features/chat/actions';
@@ -241,6 +242,24 @@ function initCommands() {
sendAnalytics(createApiEvent('avatar.url.changed'));
APP.conference.changeLocalAvatarUrl(avatarUrl);
},
+ 'send-chat-message': (message, to, ignorePrivacy = false) => {
+ logger.debug('Send chat message command received');
+ if (to) {
+ const participant = getParticipantById(APP.store.getState(), to);
+
+ if (participant) {
+ APP.store.dispatch(setPrivateMessageRecipient(participant));
+ } else {
+ logger.error(`Participant with id ${to} not found!`);
+
+ return;
+ }
+ } else {
+ APP.store.dispatch(setPrivateMessageRecipient());
+ }
+
+ APP.store.dispatch(sendMessage(message, ignorePrivacy));
+ },
'send-endpoint-text-message': (to, text) => {
logger.debug('Send endpoint message command received');
try {
diff --git a/modules/API/external/external_api.js b/modules/API/external/external_api.js
index 8152485c81..309972b017 100644
--- a/modules/API/external/external_api.js
+++ b/modules/API/external/external_api.js
@@ -41,6 +41,7 @@ const commands = {
password: 'password',
pinParticipant: 'pin-participant',
resizeLargeVideo: 'resize-large-video',
+ sendChatMessage: 'send-chat-message',
sendEndpointTextMessage: 'send-endpoint-text-message',
sendTones: 'send-tones',
setLargeVideoParticipant: 'set-large-video-participant',