2022-09-14 11:32:58 +00:00
|
|
|
import { IStore } from '../app/types';
|
2022-09-30 09:08:03 +00:00
|
|
|
import { getConferenceState } from '../base/conference/functions';
|
2021-06-23 11:23:44 +00:00
|
|
|
import { MEDIA_TYPE, type MediaType } from '../base/media/constants';
|
2022-09-14 11:32:58 +00:00
|
|
|
import { getParticipantById, isParticipantModerator } from '../base/participants/functions';
|
2022-10-20 09:11:27 +00:00
|
|
|
import { IParticipant } from '../base/participants/types';
|
2021-09-22 13:26:55 +00:00
|
|
|
import { isForceMuted } from '../participants-pane/functions';
|
2021-06-23 11:23:44 +00:00
|
|
|
|
|
|
|
import {
|
|
|
|
DISABLE_MODERATION,
|
2022-09-27 07:10:28 +00:00
|
|
|
DISMISS_PENDING_PARTICIPANT,
|
2021-06-23 11:23:44 +00:00
|
|
|
ENABLE_MODERATION,
|
|
|
|
LOCAL_PARTICIPANT_APPROVED,
|
|
|
|
LOCAL_PARTICIPANT_MODERATION_NOTIFICATION,
|
2022-09-27 07:10:28 +00:00
|
|
|
LOCAL_PARTICIPANT_REJECTED,
|
2021-06-23 11:23:44 +00:00
|
|
|
PARTICIPANT_APPROVED,
|
|
|
|
PARTICIPANT_PENDING_AUDIO,
|
2022-09-27 07:10:28 +00:00
|
|
|
PARTICIPANT_REJECTED,
|
2021-09-10 11:05:16 +00:00
|
|
|
REQUEST_DISABLE_AUDIO_MODERATION,
|
|
|
|
REQUEST_DISABLE_VIDEO_MODERATION,
|
2022-09-27 07:10:28 +00:00
|
|
|
REQUEST_ENABLE_AUDIO_MODERATION,
|
|
|
|
REQUEST_ENABLE_VIDEO_MODERATION
|
2021-06-23 11:23:44 +00:00
|
|
|
} from './actionTypes';
|
2021-09-10 11:05:16 +00:00
|
|
|
import { isEnabledFromState } from './functions';
|
2021-06-23 11:23:44 +00:00
|
|
|
|
|
|
|
/**
|
2021-09-29 13:41:23 +00:00
|
|
|
* Action used by moderator to approve audio for a participant.
|
2021-06-23 11:23:44 +00:00
|
|
|
*
|
|
|
|
* @param {staring} id - The id of the participant to be approved.
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2022-09-14 11:32:58 +00:00
|
|
|
export const approveParticipantAudio = (id: string) => (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
|
2021-09-10 11:05:16 +00:00
|
|
|
const state = getState();
|
|
|
|
const { conference } = getConferenceState(state);
|
2021-10-25 10:58:18 +00:00
|
|
|
const participant = getParticipantById(state, id);
|
2021-06-23 11:23:44 +00:00
|
|
|
|
2021-09-28 16:11:13 +00:00
|
|
|
const isAudioModerationOn = isEnabledFromState(MEDIA_TYPE.AUDIO, state);
|
|
|
|
const isVideoModerationOn = isEnabledFromState(MEDIA_TYPE.VIDEO, state);
|
2021-10-25 10:58:18 +00:00
|
|
|
const isVideoForceMuted = isForceMuted(participant, MEDIA_TYPE.VIDEO, state);
|
2021-09-22 13:26:55 +00:00
|
|
|
|
2021-10-25 10:58:18 +00:00
|
|
|
if (isAudioModerationOn || !isVideoModerationOn || !isVideoForceMuted) {
|
2022-09-30 09:08:03 +00:00
|
|
|
conference?.avModerationApprove(MEDIA_TYPE.AUDIO, id);
|
2021-09-10 11:05:16 +00:00
|
|
|
}
|
2021-09-29 13:41:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Action used by moderator to approve video for a participant.
|
|
|
|
*
|
|
|
|
* @param {staring} id - The id of the participant to be approved.
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2022-09-14 11:32:58 +00:00
|
|
|
export const approveParticipantVideo = (id: string) => (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
|
2021-09-29 13:41:23 +00:00
|
|
|
const state = getState();
|
|
|
|
const { conference } = getConferenceState(state);
|
|
|
|
const participant = getParticipantById(state, id);
|
|
|
|
|
|
|
|
const isVideoForceMuted = isForceMuted(participant, MEDIA_TYPE.VIDEO, state);
|
|
|
|
const isVideoModerationOn = isEnabledFromState(MEDIA_TYPE.VIDEO, state);
|
|
|
|
|
2021-09-28 16:11:13 +00:00
|
|
|
if (isVideoModerationOn && isVideoForceMuted) {
|
2022-09-30 09:08:03 +00:00
|
|
|
conference?.avModerationApprove(MEDIA_TYPE.VIDEO, id);
|
2021-09-10 11:05:16 +00:00
|
|
|
}
|
2021-06-23 11:23:44 +00:00
|
|
|
};
|
|
|
|
|
2021-09-29 13:41:23 +00:00
|
|
|
/**
|
|
|
|
* Action used by moderator to approve audio and video for a participant.
|
|
|
|
*
|
|
|
|
* @param {staring} id - The id of the participant to be approved.
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2022-09-14 11:32:58 +00:00
|
|
|
export const approveParticipant = (id: string) => (dispatch: IStore['dispatch']) => {
|
2021-09-29 13:41:23 +00:00
|
|
|
dispatch(approveParticipantAudio(id));
|
|
|
|
dispatch(approveParticipantVideo(id));
|
|
|
|
};
|
|
|
|
|
2021-09-28 16:11:13 +00:00
|
|
|
/**
|
|
|
|
* Action used by moderator to reject audio for a participant.
|
|
|
|
*
|
|
|
|
* @param {staring} id - The id of the participant to be rejected.
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2022-09-14 11:32:58 +00:00
|
|
|
export const rejectParticipantAudio = (id: string) => (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
|
2021-09-28 16:11:13 +00:00
|
|
|
const state = getState();
|
|
|
|
const { conference } = getConferenceState(state);
|
|
|
|
const audioModeration = isEnabledFromState(MEDIA_TYPE.AUDIO, state);
|
|
|
|
|
|
|
|
const participant = getParticipantById(state, id);
|
|
|
|
const isAudioForceMuted = isForceMuted(participant, MEDIA_TYPE.AUDIO, state);
|
|
|
|
const isModerator = isParticipantModerator(participant);
|
|
|
|
|
|
|
|
if (audioModeration && !isAudioForceMuted && !isModerator) {
|
2022-09-30 09:08:03 +00:00
|
|
|
conference?.avModerationReject(MEDIA_TYPE.AUDIO, id);
|
2021-09-28 16:11:13 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Action used by moderator to reject video for a participant.
|
|
|
|
*
|
|
|
|
* @param {staring} id - The id of the participant to be rejected.
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2022-09-14 11:32:58 +00:00
|
|
|
export const rejectParticipantVideo = (id: string) => (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
|
2021-09-28 16:11:13 +00:00
|
|
|
const state = getState();
|
|
|
|
const { conference } = getConferenceState(state);
|
|
|
|
const videoModeration = isEnabledFromState(MEDIA_TYPE.VIDEO, state);
|
|
|
|
|
|
|
|
const participant = getParticipantById(state, id);
|
|
|
|
const isVideoForceMuted = isForceMuted(participant, MEDIA_TYPE.VIDEO, state);
|
|
|
|
const isModerator = isParticipantModerator(participant);
|
|
|
|
|
|
|
|
if (videoModeration && !isVideoForceMuted && !isModerator) {
|
2022-09-30 09:08:03 +00:00
|
|
|
conference?.avModerationReject(MEDIA_TYPE.VIDEO, id);
|
2021-09-28 16:11:13 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-06-23 11:23:44 +00:00
|
|
|
/**
|
|
|
|
* Audio or video moderation is disabled.
|
|
|
|
*
|
|
|
|
* @param {MediaType} mediaType - The media type that was disabled.
|
|
|
|
* @param {JitsiParticipant} actor - The actor disabling.
|
|
|
|
* @returns {{
|
|
|
|
* type: REQUEST_DISABLE_MODERATED_AUDIO
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export const disableModeration = (mediaType: MediaType, actor: Object) => {
|
|
|
|
return {
|
|
|
|
type: DISABLE_MODERATION,
|
|
|
|
mediaType,
|
|
|
|
actor
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Hides the notification with the participant that asked to unmute audio.
|
|
|
|
*
|
2022-10-20 09:11:27 +00:00
|
|
|
* @param {IParticipant} participant - The participant for which the notification to be hidden.
|
2021-06-23 11:23:44 +00:00
|
|
|
* @returns {Object}
|
|
|
|
*/
|
2022-10-20 09:11:27 +00:00
|
|
|
export function dismissPendingAudioParticipant(participant: IParticipant) {
|
2021-08-06 19:36:08 +00:00
|
|
|
return dismissPendingParticipant(participant.id, MEDIA_TYPE.AUDIO);
|
2021-06-23 11:23:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Hides the notification with the participant that asked to unmute.
|
|
|
|
*
|
2021-08-06 19:36:08 +00:00
|
|
|
* @param {string} id - The participant id for which the notification to be hidden.
|
2021-06-23 11:23:44 +00:00
|
|
|
* @param {MediaType} mediaType - The media type.
|
|
|
|
* @returns {Object}
|
|
|
|
*/
|
2021-08-06 19:36:08 +00:00
|
|
|
export function dismissPendingParticipant(id: string, mediaType: MediaType) {
|
2021-06-23 11:23:44 +00:00
|
|
|
return {
|
|
|
|
type: DISMISS_PENDING_PARTICIPANT,
|
2021-08-06 19:36:08 +00:00
|
|
|
id,
|
2021-06-23 11:23:44 +00:00
|
|
|
mediaType
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Audio or video moderation is enabled.
|
|
|
|
*
|
|
|
|
* @param {MediaType} mediaType - The media type that was enabled.
|
|
|
|
* @param {JitsiParticipant} actor - The actor enabling.
|
|
|
|
* @returns {{
|
|
|
|
* type: REQUEST_ENABLE_MODERATED_AUDIO
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export const enableModeration = (mediaType: MediaType, actor: Object) => {
|
|
|
|
return {
|
|
|
|
type: ENABLE_MODERATION,
|
|
|
|
mediaType,
|
|
|
|
actor
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2021-09-10 11:05:16 +00:00
|
|
|
* Requests disable of audio moderation.
|
2021-06-23 11:23:44 +00:00
|
|
|
*
|
|
|
|
* @returns {{
|
2021-09-10 11:05:16 +00:00
|
|
|
* type: REQUEST_DISABLE_AUDIO_MODERATION
|
2021-06-23 11:23:44 +00:00
|
|
|
* }}
|
|
|
|
*/
|
2021-09-10 11:05:16 +00:00
|
|
|
export const requestDisableAudioModeration = () => {
|
2021-06-23 11:23:44 +00:00
|
|
|
return {
|
2021-09-10 11:05:16 +00:00
|
|
|
type: REQUEST_DISABLE_AUDIO_MODERATION
|
2021-06-23 11:23:44 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2021-09-10 11:05:16 +00:00
|
|
|
* Requests disable of video moderation.
|
2021-06-23 11:23:44 +00:00
|
|
|
*
|
|
|
|
* @returns {{
|
2021-09-10 11:05:16 +00:00
|
|
|
* type: REQUEST_DISABLE_VIDEO_MODERATION
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export const requestDisableVideoModeration = () => {
|
|
|
|
return {
|
|
|
|
type: REQUEST_DISABLE_VIDEO_MODERATION
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Requests enable of audio moderation.
|
|
|
|
*
|
|
|
|
* @returns {{
|
|
|
|
* type: REQUEST_ENABLE_AUDIO_MODERATION
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export const requestEnableAudioModeration = () => {
|
|
|
|
return {
|
|
|
|
type: REQUEST_ENABLE_AUDIO_MODERATION
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Requests enable of video moderation.
|
|
|
|
*
|
|
|
|
* @returns {{
|
|
|
|
* type: REQUEST_ENABLE_VIDEO_MODERATION
|
2021-06-23 11:23:44 +00:00
|
|
|
* }}
|
|
|
|
*/
|
2021-09-10 11:05:16 +00:00
|
|
|
export const requestEnableVideoModeration = () => {
|
2021-06-23 11:23:44 +00:00
|
|
|
return {
|
2021-09-10 11:05:16 +00:00
|
|
|
type: REQUEST_ENABLE_VIDEO_MODERATION
|
2021-06-23 11:23:44 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Local participant was approved to be able to unmute audio and video.
|
|
|
|
*
|
|
|
|
* @param {MediaType} mediaType - The media type to disable.
|
|
|
|
* @returns {{
|
|
|
|
* type: LOCAL_PARTICIPANT_APPROVED
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export const localParticipantApproved = (mediaType: MediaType) => {
|
|
|
|
return {
|
|
|
|
type: LOCAL_PARTICIPANT_APPROVED,
|
|
|
|
mediaType
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-09-28 16:11:13 +00:00
|
|
|
/**
|
|
|
|
* Local participant was blocked to be able to unmute audio and video.
|
|
|
|
*
|
|
|
|
* @param {MediaType} mediaType - The media type to disable.
|
|
|
|
* @returns {{
|
|
|
|
* type: LOCAL_PARTICIPANT_REJECTED
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export const localParticipantRejected = (mediaType: MediaType) => {
|
|
|
|
return {
|
|
|
|
type: LOCAL_PARTICIPANT_REJECTED,
|
|
|
|
mediaType
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-06-23 11:23:44 +00:00
|
|
|
/**
|
|
|
|
* Shows notification when A/V moderation is enabled and local participant is still not approved.
|
|
|
|
*
|
|
|
|
* @param {MediaType} mediaType - Audio or video media type.
|
|
|
|
* @returns {Object}
|
|
|
|
*/
|
|
|
|
export function showModeratedNotification(mediaType: MediaType) {
|
|
|
|
return {
|
|
|
|
type: LOCAL_PARTICIPANT_MODERATION_NOTIFICATION,
|
|
|
|
mediaType
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows a notification with the participant that asked to audio unmute.
|
|
|
|
*
|
2022-10-20 09:11:27 +00:00
|
|
|
* @param {IParticipant} participant - The participant for which is the notification.
|
2021-06-23 11:23:44 +00:00
|
|
|
* @returns {Object}
|
|
|
|
*/
|
2022-10-20 09:11:27 +00:00
|
|
|
export function participantPendingAudio(participant: IParticipant) {
|
2021-06-23 11:23:44 +00:00
|
|
|
return {
|
|
|
|
type: PARTICIPANT_PENDING_AUDIO,
|
2021-07-09 12:36:19 +00:00
|
|
|
participant
|
2021-06-23 11:23:44 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A participant was approved to unmute for a mediaType.
|
|
|
|
*
|
|
|
|
* @param {string} id - The id of the approved participant.
|
|
|
|
* @param {MediaType} mediaType - The media type which was approved.
|
|
|
|
* @returns {{
|
|
|
|
* type: PARTICIPANT_APPROVED,
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export function participantApproved(id: string, mediaType: MediaType) {
|
|
|
|
return {
|
|
|
|
type: PARTICIPANT_APPROVED,
|
|
|
|
id,
|
|
|
|
mediaType
|
|
|
|
};
|
|
|
|
}
|
2021-09-28 16:11:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A participant was blocked to unmute for a mediaType.
|
|
|
|
*
|
|
|
|
* @param {string} id - The id of the approved participant.
|
|
|
|
* @param {MediaType} mediaType - The media type which was approved.
|
|
|
|
* @returns {{
|
|
|
|
* type: PARTICIPANT_REJECTED,
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export function participantRejected(id: string, mediaType: MediaType) {
|
|
|
|
return {
|
|
|
|
type: PARTICIPANT_REJECTED,
|
|
|
|
id,
|
|
|
|
mediaType
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|