Browse Source

feat(API): expose recording consent to external api (#16141)

* expose recording consent to api

* Update react/features/recording/actions.web.tsx

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
j25
Andrei Gavrilescu 3 months ago
parent
commit
a4c20469cd
No account linked to committer's email address

+ 18
- 0
modules/API/API.js View File

@@ -108,6 +108,7 @@ import {
108 108
 } from '../../react/features/participants-pane/actions';
109 109
 import { getParticipantsPaneOpen, isForceMuted } from '../../react/features/participants-pane/functions';
110 110
 import { startLocalVideoRecording, stopLocalVideoRecording } from '../../react/features/recording/actions.any';
111
+import { grantRecordingConsent, grantRecordingConsentAndUnmute } from '../../react/features/recording/actions.web';
111 112
 import { RECORDING_METADATA_ID, RECORDING_TYPES } from '../../react/features/recording/constants';
112 113
 import { getActiveSession, supportsLocalRecording } from '../../react/features/recording/functions';
113 114
 import { startAudioScreenShareFlow, startScreenShareFlow } from '../../react/features/screen-share/actions';
@@ -209,6 +210,10 @@ function initCommands() {
209 210
             }
210 211
             APP.store.dispatch(grantModerator(participantId));
211 212
         },
213
+        'grant-recording-consent': unmute => {
214
+            unmute ? APP.store.dispatch(grantRecordingConsentAndUnmute())
215
+                : APP.store.dispatch(grantRecordingConsent());
216
+        },
212 217
         'display-name': displayName => {
213 218
             sendAnalytics(createApiEvent('display.name.changed'));
214 219
             APP.store.dispatch(updateSettings({ displayName: getNormalizedDisplayName(displayName) }));
@@ -1918,6 +1923,19 @@ class API {
1918 1923
         });
1919 1924
     }
1920 1925
 
1926
+    /**
1927
+     * Notify external application (if API is enabled) that the recording consent dialog open state has changed.
1928
+     *
1929
+     * @param {boolean} open - True if the dialog is open, false otherwise.
1930
+     * @returns {void}
1931
+     */
1932
+    notifyRecordingConsentDialogOpen(open) {
1933
+        this._sendEvent({
1934
+            name: 'recording-consent-dialog-open',
1935
+            open
1936
+        });
1937
+    }
1938
+
1921 1939
     /**
1922 1940
      * Notify external application of the current meeting requiring a password
1923 1941
      * to join.

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

@@ -38,6 +38,7 @@ const commands = {
38 38
     endConference: 'end-conference',
39 39
     email: 'email',
40 40
     grantModerator: 'grant-moderator',
41
+    grantRecordingConsent: 'grant-recording-consent',
41 42
     hangup: 'video-hangup',
42 43
     hideNotification: 'hide-notification',
43 44
     initiatePrivateChat: 'initiate-private-chat',
@@ -151,6 +152,7 @@ const events = {
151 152
     'proxy-connection-event': 'proxyConnectionEvent',
152 153
     'raise-hand-updated': 'raiseHandUpdated',
153 154
     'ready': 'ready',
155
+    'recording-consent-dialog-open': 'recordingConsentDialogOpen',
154 156
     'recording-link-available': 'recordingLinkAvailable',
155 157
     'recording-status-changed': 'recordingStatusChanged',
156 158
     'participant-menu-button-clicked': 'participantMenuButtonClick',

+ 41
- 1
react/features/recording/actions.web.tsx View File

@@ -1,8 +1,16 @@
1 1
 import React from 'react';
2
+import { batch } from 'react-redux';
2 3
 
3 4
 import { IStore } from '../app/types';
4
-import { openDialog } from '../base/dialog/actions';
5
+import { hideDialog, openDialog } from '../base/dialog/actions';
5 6
 import JitsiMeetJS from '../base/lib-jitsi-meet';
7
+import {
8
+    setAudioMuted,
9
+    setAudioUnmutePermissions,
10
+    setVideoMuted,
11
+    setVideoUnmutePermissions
12
+} from '../base/media/actions';
13
+import { VIDEO_MUTISM_AUTHORITY } from '../base/media/constants';
6 14
 import { showNotification } from '../notifications/actions';
7 15
 import { NOTIFICATION_TIMEOUT_TYPE } from '../notifications/constants';
8 16
 
@@ -12,6 +20,38 @@ import RecordingLimitNotificationDescription from './components/web/RecordingLim
12 20
 
13 21
 export * from './actions.any';
14 22
 
23
+/**
24
+ * Grants recording consent by setting audio and video unmute permissions.
25
+ *
26
+ * @returns {Function}
27
+ */
28
+export function grantRecordingConsent() {
29
+    return (dispatch: IStore['dispatch']) => {
30
+        batch(() => {
31
+            dispatch(setAudioUnmutePermissions(false, true));
32
+            dispatch(setVideoUnmutePermissions(false, true));
33
+            dispatch(hideDialog());
34
+        });
35
+    };
36
+}
37
+
38
+/**
39
+ * Grants recording consent, unmutes audio/video, and closes the dialog.
40
+ *
41
+ * @returns {Function}
42
+ */
43
+export function grantRecordingConsentAndUnmute() {
44
+    return (dispatch: IStore['dispatch']) => {
45
+        batch(() => {
46
+            dispatch(setAudioUnmutePermissions(false, true));
47
+            dispatch(setVideoUnmutePermissions(false, true));
48
+            dispatch(setAudioMuted(false, true));
49
+            dispatch(setVideoMuted(false, VIDEO_MUTISM_AUTHORITY.USER, true));
50
+            dispatch(hideDialog());
51
+        });
52
+    };
53
+}
54
+
15 55
 /**
16 56
  * Signals that a started recording notification should be shown on the
17 57
  * screen for a given period.

+ 14
- 21
react/features/recording/components/Recording/web/RecordingConsentDialog.tsx View File

@@ -1,18 +1,12 @@
1
-import React, { useCallback } from 'react';
1
+import React, { useCallback, useEffect } from 'react';
2 2
 import { useTranslation } from 'react-i18next';
3
-import { batch, useDispatch, useSelector } from 'react-redux';
3
+import { useDispatch, useSelector } from 'react-redux';
4 4
 
5 5
 import { IReduxState } from '../../../../app/types';
6
-import { hideDialog } from '../../../../base/dialog/actions';
7 6
 import { translateToHTML } from '../../../../base/i18n/functions';
8
-import {
9
-    setAudioMuted,
10
-    setAudioUnmutePermissions,
11
-    setVideoMuted,
12
-    setVideoUnmutePermissions
13
-} from '../../../../base/media/actions';
14
-import { VIDEO_MUTISM_AUTHORITY } from '../../../../base/media/constants';
15 7
 import Dialog from '../../../../base/ui/components/web/Dialog';
8
+import { grantRecordingConsent, grantRecordingConsentAndUnmute } from '../../../actions.web';
9
+
16 10
 
17 11
 /**
18 12
  * Component that renders the dialog for explicit consent for recordings.
@@ -26,21 +20,20 @@ export default function RecordingConsentDialog() {
26 20
     const { consentLearnMoreLink } = recordings ?? {};
27 21
     const learnMore = ` (<a href="${consentLearnMoreLink}" target="_blank" rel="noopener noreferrer">${t('dialog.learnMore')}</a>)`;
28 22
 
23
+    useEffect(() => {
24
+        APP.API.notifyRecordingConsentDialogOpen(true);
25
+
26
+        return () => {
27
+            APP.API.notifyRecordingConsentDialogOpen(false);
28
+        };
29
+    }, []);
30
+
29 31
     const consent = useCallback(() => {
30
-        batch(() => {
31
-            dispatch(setAudioUnmutePermissions(false, true));
32
-            dispatch(setVideoUnmutePermissions(false, true));
33
-        });
32
+        dispatch(grantRecordingConsent());
34 33
     }, []);
35 34
 
36 35
     const consentAndUnmute = useCallback(() => {
37
-        batch(() => {
38
-            dispatch(setAudioUnmutePermissions(false, true));
39
-            dispatch(setVideoUnmutePermissions(false, true));
40
-            dispatch(setAudioMuted(false, true));
41
-            dispatch(setVideoMuted(false, VIDEO_MUTISM_AUTHORITY.USER, true));
42
-            dispatch(hideDialog());
43
-        });
36
+        dispatch(grantRecordingConsentAndUnmute());
44 37
     }, []);
45 38
 
46 39
     return (

Loading…
Cancel
Save