| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314 | 
							- // @flow
 - 
 - import { getConferenceState } from '../base/conference';
 - import { MEDIA_TYPE, type MediaType } from '../base/media/constants';
 - import { getParticipantById, isParticipantModerator } from '../base/participants';
 - import { isForceMuted } from '../participants-pane/functions';
 - 
 - import {
 -     DISMISS_PENDING_PARTICIPANT,
 -     DISABLE_MODERATION,
 -     ENABLE_MODERATION,
 -     LOCAL_PARTICIPANT_APPROVED,
 -     LOCAL_PARTICIPANT_MODERATION_NOTIFICATION,
 -     PARTICIPANT_APPROVED,
 -     PARTICIPANT_PENDING_AUDIO,
 -     REQUEST_DISABLE_AUDIO_MODERATION,
 -     REQUEST_ENABLE_AUDIO_MODERATION,
 -     REQUEST_DISABLE_VIDEO_MODERATION,
 -     REQUEST_ENABLE_VIDEO_MODERATION,
 -     LOCAL_PARTICIPANT_REJECTED,
 -     PARTICIPANT_REJECTED
 - } from './actionTypes';
 - import { isEnabledFromState } from './functions';
 - 
 - /**
 -  * Action used by moderator to approve audio for a participant.
 -  *
 -  * @param {staring} id - The id of the participant to be approved.
 -  * @returns {void}
 -  */
 - export const approveParticipantAudio = (id: string) => (dispatch: Function, getState: Function) => {
 -     const state = getState();
 -     const { conference } = getConferenceState(state);
 - 
 -     const isAudioModerationOn = isEnabledFromState(MEDIA_TYPE.AUDIO, state);
 -     const isVideoModerationOn = isEnabledFromState(MEDIA_TYPE.VIDEO, state);
 - 
 -     if (isAudioModerationOn || !isVideoModerationOn) {
 -         conference.avModerationApprove(MEDIA_TYPE.AUDIO, id);
 -     }
 - };
 - 
 - /**
 -  * Action used by moderator to approve video for a participant.
 -  *
 -  * @param {staring} id - The id of the participant to be approved.
 -  * @returns {void}
 -  */
 - export const approveParticipantVideo = (id: string) => (dispatch: Function, getState: Function) => {
 -     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);
 - 
 -     if (isVideoModerationOn && isVideoForceMuted) {
 -         conference.avModerationApprove(MEDIA_TYPE.VIDEO, id);
 -     }
 - };
 - 
 - /**
 -  * 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}
 -  */
 - export const approveParticipant = (id: string) => (dispatch: Function) => {
 -     dispatch(approveParticipantAudio(id));
 -     dispatch(approveParticipantVideo(id));
 - };
 - 
 - /**
 -  * Action used by moderator to reject audio for a participant.
 -  *
 -  * @param {staring} id - The id of the participant to be rejected.
 -  * @returns {void}
 -  */
 - export const rejectParticipantAudio = (id: string) => (dispatch: Function, getState: Function) => {
 -     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) {
 -         conference.avModerationReject(MEDIA_TYPE.AUDIO, id);
 -     }
 - };
 - 
 - /**
 -  * Action used by moderator to reject video for a participant.
 -  *
 -  * @param {staring} id - The id of the participant to be rejected.
 -  * @returns {void}
 -  */
 - export const rejectParticipantVideo = (id: string) => (dispatch: Function, getState: Function) => {
 -     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) {
 -         conference.avModerationReject(MEDIA_TYPE.VIDEO, id);
 -     }
 - };
 - 
 - /**
 -  * 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.
 -  *
 -  * @param {Object} participant - The participant for which the notification to be hidden.
 -  * @returns {Object}
 -  */
 - export function dismissPendingAudioParticipant(participant: Object) {
 -     return dismissPendingParticipant(participant.id, MEDIA_TYPE.AUDIO);
 - }
 - 
 - /**
 -  * Hides the notification with the participant that asked to unmute.
 -  *
 -  * @param {string} id - The participant id for which the notification to be hidden.
 -  * @param {MediaType} mediaType - The media type.
 -  * @returns {Object}
 -  */
 - export function dismissPendingParticipant(id: string, mediaType: MediaType) {
 -     return {
 -         type: DISMISS_PENDING_PARTICIPANT,
 -         id,
 -         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
 -     };
 - };
 - 
 - /**
 -  * Requests disable of audio moderation.
 -  *
 -  * @returns {{
 -  *     type: REQUEST_DISABLE_AUDIO_MODERATION
 -  * }}
 -  */
 - export const requestDisableAudioModeration = () => {
 -     return {
 -         type: REQUEST_DISABLE_AUDIO_MODERATION
 -     };
 - };
 - 
 - /**
 -  * Requests disable of video moderation.
 -  *
 -  * @returns {{
 -  *     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
 -  * }}
 -  */
 - export const requestEnableVideoModeration = () => {
 -     return {
 -         type: REQUEST_ENABLE_VIDEO_MODERATION
 -     };
 - };
 - 
 - /**
 -  * 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
 -     };
 - };
 - 
 - /**
 -  * 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
 -     };
 - };
 - 
 - /**
 -  * 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.
 -  *
 -  * @param {Object} participant - The participant for which is the notification.
 -  * @returns {Object}
 -  */
 - export function participantPendingAudio(participant: Object) {
 -     return {
 -         type: PARTICIPANT_PENDING_AUDIO,
 -         participant
 -     };
 - }
 - 
 - /**
 -  * 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
 -     };
 - }
 - 
 - /**
 -  * 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
 -     };
 - }
 
 
  |