Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
fix(visitors): Disable polls.
Hristo Terezov4a5ba0f05d58
diff --git a/react/features/chat/components/native/ChatButton.ts b/react/features/chat/components/native/ChatButton.tsindex 361b0e3d63..9fd01bb620 100644--- a/react/features/chat/components/native/ChatButton.ts+++ b/react/features/chat/components/native/ChatButton.ts@@ -6,6 +6,7 @@ import { getFeatureFlag } from '../../../base/flags/functions';import { translate } from '../../../base/i18n/functions';import { IconChatUnread, IconMessage } from '../../../base/icons/svg';import AbstractButton, { IProps as AbstractButtonProps } from '../../../base/toolbox/components/AbstractButton';+import { arePollsDisabled } from '../../../conference/functions.any';import { navigate } from '../../../mobile/navigation/components/conference/ConferenceNavigationContainerRef';import { screen } from '../../../mobile/navigation/routes';import { getUnreadPollCount } from '../../../polls/functions';@@ -65,11 +66,10 @@ class ChatButton extends AbstractButton<IProps> {*/function _mapStateToProps(state: IReduxState, ownProps: any) {const enabled = getFeatureFlag(state, CHAT_ENABLED, true);- const { disablePolls } = state['features/base/config'];const { visible = enabled } = ownProps;return {- _isPollsDisabled: disablePolls,+ _isPollsDisabled: arePollsDisabled(state),// The toggled icon should also be available for new polls_unreadMessageCount: getUnreadCount(state) || getUnreadPollCount(state),diff --git a/react/features/chat/components/native/PrivateMessageButton.tsx b/react/features/chat/components/native/PrivateMessageButton.tsxindex 195a238384..0e5308546c 100644--- a/react/features/chat/components/native/PrivateMessageButton.tsx+++ b/react/features/chat/components/native/PrivateMessageButton.tsx@@ -8,6 +8,7 @@ import { IconMessage, IconReply } from '../../../base/icons/svg';import { getParticipantById } from '../../../base/participants/functions';import { IParticipant } from '../../../base/participants/types';import AbstractButton, { IProps as AbstractButtonProps } from '../../../base/toolbox/components/AbstractButton';+import { arePollsDisabled } from '../../../conference/functions.any';import { navigate } from '../../../mobile/navigation/components/conference/ConferenceNavigationContainerRef';import { screen } from '../../../mobile/navigation/routes';import { handleLobbyChatInitialized, openChat } from '../../actions.native';@@ -96,11 +97,10 @@ class PrivateMessageButton extends AbstractButton<IProps, any> {*/export function _mapStateToProps(state: IReduxState, ownProps: any) {const enabled = getFeatureFlag(state, CHAT_ENABLED, true);- const { disablePolls } = state['features/base/config'];const { visible = enabled, isLobbyMessage, participantID } = ownProps;return {- _isPollsDisabled: disablePolls,+ _isPollsDisabled: arePollsDisabled(state),_participant: getParticipantById(state, participantID),_isLobbyMessage: isLobbyMessage,visiblediff --git a/react/features/chat/components/web/Chat.tsx b/react/features/chat/components/web/Chat.tsxindex dd801ca01b..f25a71a429 100644--- a/react/features/chat/components/web/Chat.tsx+++ b/react/features/chat/components/web/Chat.tsx@@ -7,6 +7,7 @@ import { translate } from '../../../base/i18n/functions';import { getLocalParticipant } from '../../../base/participants/functions';import { withPixelLineHeight } from '../../../base/styles/functions.web';import Tabs from '../../../base/ui/components/web/Tabs';+import { arePollsDisabled } from '../../../conference/functions.any';import PollsPane from '../../../polls/components/web/PollsPane';import { sendMessage, setIsPollsTabFocused, toggleChat } from '../../actions.web';import { CHAT_SIZE, CHAT_TABS, SMALL_WIDTH_THRESHOLD } from '../../constants';@@ -316,12 +317,11 @@ function _mapStateToProps(state: IReduxState, _ownProps: any) {const { isOpen, isPollsTabFocused, messages, nbUnreadMessages } = state['features/chat'];const { nbUnreadPolls } = state['features/polls'];const _localParticipant = getLocalParticipant(state);- const { disablePolls } = state['features/base/config'];return {_isModal: window.innerWidth <= SMALL_WIDTH_THRESHOLD,_isOpen: isOpen,- _isPollsEnabled: !disablePolls,+ _isPollsEnabled: !arePollsDisabled(state),_isPollsTabFocused: isPollsTabFocused,_messages: messages,_nbUnreadMessages: nbUnreadMessages,diff --git a/react/features/conference/functions.any.ts b/react/features/conference/functions.any.tsindex 5e4db2d206..474d4eecfa 100644--- a/react/features/conference/functions.any.ts+++ b/react/features/conference/functions.any.ts@@ -1,5 +1,6 @@import { IStateful } from '../base/app/types';import { toState } from '../base/redux/functions';+import { iAmVisitor } from '../visitors/functions';/**@@ -15,3 +16,19 @@ export function shouldDisplayNotifications(stateful: IStateful) {return !calleeInfoVisible;}+++/**+ *+ * Returns true if polls feature is disabled.+ *+ * @param {(Function|Object)} stateful - The (whole) redux state, or redux's+ * {@code getState} function to be used to retrieve the state+ * features/base/config.+ * @returns {boolean}.+ */+export function arePollsDisabled(stateful: IStateful) {+ const state = toState(stateful);++ return state['features/base/config']?.disablePolls || iAmVisitor(state);+}diff --git a/react/features/conference/functions.native.ts b/react/features/conference/functions.native.tsindex d62a013613..fb2a6bc39a 100644--- a/react/features/conference/functions.native.ts+++ b/react/features/conference/functions.native.ts@@ -1,21 +1 @@-import { IStateful } from '../base/app/types';-import { toState } from '../base/redux/functions';-export * from './functions.any';---/**- *- * Returns true if polls feature is disabled.- *- * @param {(Function|Object)} stateful - The (whole) redux state, or redux's- * {@code getState} function to be used to retrieve the state- * features/base/config.- * @returns {boolean}.- */-export function getDisablePolls(stateful: IStateful) {- const state = toState(stateful)['features/base/config'];-- return state.disablePolls;-}-diff --git a/react/features/lobby/middleware.ts b/react/features/lobby/middleware.tsindex 503d4d6347..b6e5757018 100644--- a/react/features/lobby/middleware.ts+++ b/react/features/lobby/middleware.ts@@ -31,6 +31,7 @@ import {handleLobbyChatInitialized,removeLobbyChatParticipant} from '../chat/actions.any';+import { arePollsDisabled } from '../conference/functions.any';import { hideNotification, showNotification } from '../notifications/actions';import {LOBBY_NOTIFICATION_ID,@@ -201,7 +202,6 @@ function _handleLobbyNotification(store: IStore) {if (knockingParticipants.length === 1) {const firstParticipant = knockingParticipants[0];- const { disablePolls } = getState()['features/base/config'];const showChat = showLobbyChatButton(firstParticipant)(getState());descriptionKey = 'notify.participantWantsToJoin';@@ -225,7 +225,7 @@ function _handleLobbyNotification(store: IStore) {customActionType.splice(1, 0, BUTTON_TYPES.SECONDARY);customActionHandler.splice(1, 0, () => batch(() => {dispatch(handleLobbyChatInitialized(firstParticipant.id));- dispatch(openChat({}, disablePolls));+ dispatch(openChat({}, arePollsDisabled(getState())));}));}} else {diff --git a/react/features/mobile/navigation/components/conference/components/ConferenceNavigationContainer.tsx b/react/features/mobile/navigation/components/conference/components/ConferenceNavigationContainer.tsxindex 7c27edbf74..22b6b02487 100644--- a/react/features/mobile/navigation/components/conference/components/ConferenceNavigationContainer.tsx+++ b/react/features/mobile/navigation/components/conference/components/ConferenceNavigationContainer.tsx@@ -16,7 +16,7 @@ import Conference from '../../../../../conference/components/native/Conference';// @ts-ignoreimport CarMode from '../../../../../conference/components/native/carmode/CarMode';// @ts-ignore-import { getDisablePolls } from '../../../../../conference/functions';+import { arePollsDisabled } from '../../../../../conference/functions';// @ts-ignoreimport SharedDocument from '../../../../../etherpad/components/native/SharedDocument';// @ts-ignore@@ -81,7 +81,7 @@ const ConferenceStack = createStackNavigator();const ConferenceNavigationContainer = () => {- const isPollsDisabled = useSelector(getDisablePolls);+ const isPollsDisabled = useSelector(arePollsDisabled);let ChatScreen;let chatScreenName;let chatTitleString;diff --git a/react/features/polls/middleware.ts b/react/features/polls/middleware.tsindex 8205627057..d062e30161 100644--- a/react/features/polls/middleware.ts+++ b/react/features/polls/middleware.ts@@ -6,6 +6,7 @@ import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';import StateListenerRegistry from '../base/redux/StateListenerRegistry';import { playSound } from '../base/sounds/actions';import { INCOMING_MSG_SOUND_ID } from '../chat/constants';+import { arePollsDisabled } from '../conference/functions.any';import { showNotification } from '../notifications/actions';import { NOTIFICATION_TIMEOUT_TYPE, NOTIFICATION_TYPE } from '../notifications/constants';@@ -69,7 +70,7 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {...data,senderId: isNewPoll ? user._id : undefined,voterId: isNewPoll ? undefined : user._id- }, dispatch);+ }, dispatch, getState);});conference.on(JitsiConferenceEvents.NON_PARTICIPANT_MESSAGE_RECEIVED,(id: any, data: any) => {@@ -79,7 +80,7 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {...data,senderId: isNewPoll ? id : undefined,voterId: isNewPoll ? undefined : id- }, dispatch);+ }, dispatch, getState);});break;@@ -89,6 +90,11 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {case RECEIVE_POLL: {const state = getState();++ if (arePollsDisabled(state)) {+ break;+ }+const isChatOpen: boolean = state['features/chat'].isOpen;const isPollsTabFocused: boolean = state['features/chat'].isPollsTabFocused;@@ -109,10 +115,15 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {** @param {Object} data - The json data carried by the polls message.* @param {Function} dispatch - The dispatch function.+ * @param {Function} getState - The getState function.** @returns {void}*/-function _handleReceivePollsMessage(data: any, dispatch: IStore['dispatch']) {+function _handleReceivePollsMessage(data: any, dispatch: IStore['dispatch'], getState: IStore['getState']) {+ if (arePollsDisabled(getState())) {+ return;+ }+switch (data.type) {case COMMAND_NEW_POLL: {const { question, answers, pollId, senderId } = data;