Просмотр исходного кода

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

j8
hmuresan 4 лет назад
Родитель
Сommit
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
 import { updateSettings } from '../../react/features/base/settings';
27
 import { updateSettings } from '../../react/features/base/settings';
28
 import { isToggleCameraEnabled, toggleCamera } from '../../react/features/base/tracks';
28
 import { isToggleCameraEnabled, toggleCamera } from '../../react/features/base/tracks';
29
 import {
29
 import {
30
+    sendMessage,
30
     setPrivateMessageRecipient,
31
     setPrivateMessageRecipient,
31
     toggleChat
32
     toggleChat
32
 } from '../../react/features/chat/actions';
33
 } from '../../react/features/chat/actions';
241
             sendAnalytics(createApiEvent('avatar.url.changed'));
242
             sendAnalytics(createApiEvent('avatar.url.changed'));
242
             APP.conference.changeLocalAvatarUrl(avatarUrl);
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
         'send-endpoint-text-message': (to, text) => {
263
         'send-endpoint-text-message': (to, text) => {
245
             logger.debug('Send endpoint message command received');
264
             logger.debug('Send endpoint message command received');
246
             try {
265
             try {

+ 1
- 0
modules/API/external/external_api.js Просмотреть файл

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

Загрузка…
Отмена
Сохранить