瀏覽代碼

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

master
hmuresan 3 年之前
父節點
當前提交
1d45edbb27
共有 2 個檔案被更改,包括 20 行新增0 行删除
  1. 19
    0
      modules/API/API.js
  2. 1
    0
      modules/API/external/external_api.js

+ 19
- 0
modules/API/API.js 查看文件

@@ -27,6 +27,7 @@ import {
27 27
 import { updateSettings } from '../../react/features/base/settings';
28 28
 import { isToggleCameraEnabled, toggleCamera } from '../../react/features/base/tracks';
29 29
 import {
30
+    sendMessage,
30 31
     setPrivateMessageRecipient,
31 32
     toggleChat
32 33
 } from '../../react/features/chat/actions';
@@ -241,6 +242,24 @@ function initCommands() {
241 242
             sendAnalytics(createApiEvent('avatar.url.changed'));
242 243
             APP.conference.changeLocalAvatarUrl(avatarUrl);
243 244
         },
245
+        'send-chat-message': (message, to, ignorePrivacy = false) => {
246
+            logger.debug('Send chat message command received');
247
+            if (to) {
248
+                const participant = getParticipantById(APP.store.getState(), to);
249
+
250
+                if (participant) {
251
+                    APP.store.dispatch(setPrivateMessageRecipient(participant));
252
+                } else {
253
+                    logger.error(`Participant with id ${to} not found!`);
254
+
255
+                    return;
256
+                }
257
+            } else {
258
+                APP.store.dispatch(setPrivateMessageRecipient());
259
+            }
260
+
261
+            APP.store.dispatch(sendMessage(message, ignorePrivacy));
262
+        },
244 263
         'send-endpoint-text-message': (to, text) => {
245 264
             logger.debug('Send endpoint message command received');
246 265
             try {

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

@@ -41,6 +41,7 @@ const commands = {
41 41
     password: 'password',
42 42
     pinParticipant: 'pin-participant',
43 43
     resizeLargeVideo: 'resize-large-video',
44
+    sendChatMessage: 'send-chat-message',
44 45
     sendEndpointTextMessage: 'send-endpoint-text-message',
45 46
     sendTones: 'send-tones',
46 47
     setLargeVideoParticipant: 'set-large-video-participant',

Loading…
取消
儲存