feat(external-api): add knocking event and approve/reject command (#10210)

This commit is contained in:
Mihaela Dumitru 2021-10-21 10:39:13 +03:00 committed by GitHub
parent b250f21f91
commit f435fc4ade
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 1 deletions

View File

@ -61,7 +61,7 @@ import {
captureLargeVideoScreenshot,
resizeLargeVideo
} from '../../react/features/large-video/actions.web';
import { toggleLobbyMode } from '../../react/features/lobby/actions';
import { toggleLobbyMode, setKnockingParticipantApproval } from '../../react/features/lobby/actions';
import { isForceMuted } from '../../react/features/participants-pane/functions';
import { RECORDING_TYPES } from '../../react/features/recording/constants';
import { getActiveSession } from '../../react/features/recording/functions';
@ -113,6 +113,9 @@ let videoAvailable = true;
*/
function initCommands() {
commands = {
'answer-knocking-participant': (id, approved) => {
APP.store.dispatch(setKnockingParticipantApproval(id, approved));
},
'approve-video': participantId => {
if (!isLocalParticipantModerator(APP.store.getState())) {
return;
@ -1458,6 +1461,19 @@ class API {
});
}
/**
* Notify external application (if API is enabled) that a participant is knocking in the lobby.
*
* @param {Object} participant - Participant data such as id and name.
* @returns {void}
*/
notifyKnockingParticipant(participant: Object) {
this._sendEvent({
name: 'knocking-participant',
participant
});
}
/**
* Notify external application (if API is enabled) that an error occured.
*

View File

@ -27,6 +27,7 @@ const ALWAYS_ON_TOP_FILENAMES = [
* commands expected by jitsi-meet
*/
const commands = {
answerKnockingParticipant: 'answer-knocking-participant',
approveVideo: 'approve-video',
askToUnmute: 'ask-to-unmute',
avatarUrl: 'avatar-url',
@ -94,6 +95,7 @@ const events = {
'feedback-prompt-displayed': 'feedbackPromptDisplayed',
'filmstrip-display-changed': 'filmstripDisplayChanged',
'incoming-message': 'incomingMessage',
'knocking-participant': 'knockingParticipant',
'log': 'log',
'mic-error': 'micError',
'moderation-participant-approved': 'moderationParticipantApproved',

View File

@ -25,6 +25,8 @@ import {
import { KNOCKING_PARTICIPANT_SOUND_ID } from './constants';
import { KNOCKING_PARTICIPANT_FILE } from './sounds';
declare var APP: Object;
MiddlewareRegistry.register(store => next => action => {
switch (action.type) {
case APP_WILL_MOUNT:
@ -69,6 +71,12 @@ StateListenerRegistry.register(
name
}));
dispatch(playSound(KNOCKING_PARTICIPANT_SOUND_ID));
if (typeof APP !== 'undefined') {
APP.API.notifyKnockingParticipant({
id,
name
});
}
});
});