Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

feat(visitors): Checks for visitors support per room.

damenchoc8cd80a8dfa9
diff --git a/react/features/video-menu/components/web/LocalVideoMenuTriggerButton.tsx b/react/features/video-menu/components/web/LocalVideoMenuTriggerButton.tsx
index 7a1599c453..8758591883 100644
--- a/react/features/video-menu/components/web/LocalVideoMenuTriggerButton.tsx
+++ b/react/features/video-menu/components/web/LocalVideoMenuTriggerButton.tsx
@@ -150,6 +150,7 @@ const LocalVideoMenuTriggerButton = ({
const { classes } = useStyles();
const { t } = useTranslation();
const buttonsWithNotifyClick = useSelector(getParticipantMenuButtonsWithNotifyClick);
+ const visitorsSupported = useSelector((state: IReduxState) => state['features/visitors'].supported);
const notifyClick = useCallback(
(buttonKey: string) => {
@@ -214,7 +215,7 @@ const LocalVideoMenuTriggerButton = ({
participantID = { _localParticipantId } />
}
{
- _showDemote && <DemoteToVisitorButton
+ _showDemote && visitorsSupported && <DemoteToVisitorButton
className = { _overflowDrawer ? classes.flipText : '' }
noIcon = { true }
// eslint-disable-next-line react/jsx-no-bind
diff --git a/react/features/video-menu/components/web/ParticipantContextMenu.tsx b/react/features/video-menu/components/web/ParticipantContextMenu.tsx
index 3b83ce69a7..cc7d3963f8 100644
--- a/react/features/video-menu/components/web/ParticipantContextMenu.tsx
+++ b/react/features/video-menu/components/web/ParticipantContextMenu.tsx
@@ -142,6 +142,7 @@ const ParticipantContextMenu = ({
const { remoteVideoMenu = {}, disableRemoteMute, startSilent, customParticipantMenuButtons }
= useSelector((state: IReduxState) => state['features/base/config']);
const visitorsMode = useSelector((state: IReduxState) => iAmVisitor(state));
+ const visitorsSupported = useSelector((state: IReduxState) => state['features/visitors'].supported);
const { disableDemote, disableKick, disableGrantModerator, disablePrivateChat } = remoteVideoMenu;
const { participantsVolume } = useSelector((state: IReduxState) => state['features/filmstrip']);
const _volume = (participant?.local ?? true ? undefined
@@ -246,7 +247,7 @@ const ParticipantContextMenu = ({
buttons2.push(<GrantModeratorButton { ...getButtonProps(BUTTONS.GRANT_MODERATOR) } />);
}
- if (!disableDemote && _isModerator) {
+ if (!disableDemote && visitorsSupported && _isModerator) {
buttons2.push(<DemoteToVisitorButton { ...getButtonProps(BUTTONS.DEMOTE) } />);
}
diff --git a/react/features/visitors/actionTypes.ts b/react/features/visitors/actionTypes.ts
index f8cef5d695..4dfdbc6e31 100644
--- a/react/features/visitors/actionTypes.ts
+++ b/react/features/visitors/actionTypes.ts
@@ -48,3 +48,13 @@ export const CLEAR_VISITOR_PROMOTION_REQUEST = 'CLEAR_VISITOR_PROMOTION_REQUEST'
* }
*/
export const SET_VISITOR_DEMOTE_ACTOR = 'SET_VISITOR_DEMOTE_ACTOR';
+
+/**
+ * The type of (redux) action which sets visitors support.
+ *
+ * {
+ * type: SET_VISITORS_SUPPORTED,
+ * value: string
+ * }
+ */
+export const SET_VISITORS_SUPPORTED = 'SET_VISITORS_SUPPORTED';
diff --git a/react/features/visitors/actions.ts b/react/features/visitors/actions.ts
index 73414438b8..9dcdeea66d 100644
--- a/react/features/visitors/actions.ts
+++ b/react/features/visitors/actions.ts
@@ -8,6 +8,7 @@ import { getLocalParticipant } from '../base/participants/functions';
import {
CLEAR_VISITOR_PROMOTION_REQUEST,
I_AM_VISITOR_MODE,
+ SET_VISITORS_SUPPORTED,
SET_VISITOR_DEMOTE_ACTOR,
UPDATE_VISITORS_COUNT,
VISITOR_PROMOTION_REQUEST
@@ -164,6 +165,21 @@ export function setVisitorDemoteActor(displayName: string | undefined) {
};
}
+/**
+ * Visitors count has been updated.
+ *
+ * @param {boolean} value - The new value whether visitors are supported.
+ * @returns {{
+ * type: SET_VISITORS_SUPPORTED,
+ * }}
+ */
+export function setVisitorsSupported(value: boolean) {
+ return {
+ type: SET_VISITORS_SUPPORTED,
+ value
+ };
+}
+
/**
* Visitors count has been updated.
*
diff --git a/react/features/visitors/middleware.ts b/react/features/visitors/middleware.ts
index 591eda3bac..d2c3f909d2 100644
--- a/react/features/visitors/middleware.ts
+++ b/react/features/visitors/middleware.ts
@@ -29,6 +29,7 @@ import {
denyRequest,
promotionRequestReceived,
setVisitorDemoteActor,
+ setVisitorsSupported,
updateVisitorsCount
} from './actions';
import { getPromotionRequests } from './functions';
@@ -70,6 +71,11 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
// check for demote actor and update notification
dispatch(showNotification(notificationParams, NOTIFICATION_TIMEOUT_TYPE.STICKY));
+ } else {
+ dispatch(setVisitorsSupported(conference.isVisitorsSupported()));
+ conference.on(JitsiConferenceEvents.VISITORS_SUPPORTED_CHANGED, (value: boolean) => {
+ dispatch(setVisitorsSupported(value));
+ });
}
conference.on(JitsiConferenceEvents.VISITORS_MESSAGE, (
diff --git a/react/features/visitors/reducer.ts b/react/features/visitors/reducer.ts
index d5bbc33ac1..58fbf9e0c7 100644
--- a/react/features/visitors/reducer.ts
+++ b/react/features/visitors/reducer.ts
@@ -4,6 +4,7 @@ import ReducerRegistry from '../base/redux/ReducerRegistry';
import {
CLEAR_VISITOR_PROMOTION_REQUEST,
I_AM_VISITOR_MODE,
+ SET_VISITORS_SUPPORTED,
SET_VISITOR_DEMOTE_ACTOR,
UPDATE_VISITORS_COUNT,
VISITOR_PROMOTION_REQUEST
@@ -14,6 +15,7 @@ const DEFAULT_STATE = {
count: -1,
iAmVisitor: false,
showNotification: false,
+ supported: false,
promotionRequests: []
};
@@ -22,6 +24,7 @@ export interface IVisitorsState {
demoteActorDisplayName?: string;
iAmVisitor: boolean;
promotionRequests: IPromotionRequest[];
+ supported: boolean;
}
ReducerRegistry.register<IVisitorsState>('features/visitors', (state = DEFAULT_STATE, action): IVisitorsState => {
switch (action.type) {
@@ -58,6 +61,12 @@ ReducerRegistry.register<IVisitorsState>('features/visitors', (state = DEFAULT_S
demoteActorDisplayName: action.displayName
};
}
+ case SET_VISITORS_SUPPORTED: {
+ return {
+ ...state,
+ supported: action.value
+ };
+ }
case VISITOR_PROMOTION_REQUEST: {
const currentRequests = state.promotionRequests || [];
diff --git a/resources/prosody-plugins/mod_visitors_component.lua b/resources/prosody-plugins/mod_visitors_component.lua
index c56e79c315..a1303d18da 100644
--- a/resources/prosody-plugins/mod_visitors_component.lua
+++ b/resources/prosody-plugins/mod_visitors_component.lua
@@ -31,6 +31,10 @@ local ignore_list = module:context(muc_domain_base):get_option_set('visitors_ign
local auto_allow_promotion = module:get_option_boolean('auto_allow_visitor_promotion', false);
+-- whether to always advertise that visitors feature is enabled for rooms
+-- can be set to off and being controlled by another module, turning it on and off for rooms
+local always_visitors_enabled = module:get_option_boolean('always_visitors_enabled', true);
+
local function is_admin(jid)
return um_is_admin(jid, module.host);
end
@@ -434,6 +438,22 @@ process_host_module(muc_domain_prefix..'.'..muc_domain_base, function(host_modul
return true; -- halt processing, but return true that we handled it
end);
+
+ if always_visitors_enabled then
+ local visitorsEnabledField = {
+ name = "muc#roominfo_visitorsEnabled";
+ type = "boolean";
+ label = "Whether visitors are enabled.";
+ value = 1;
+ };
+ -- Append "visitors enabled" to the MUC config form.
+ host_module:context(host):hook("muc-disco#info", function(event)
+ table.insert(event.form, visitorsEnabledField);
+ end);
+ host_module:context(host):hook("muc-config-form", function(event)
+ table.insert(event.form, visitorsEnabledField);
+ end);
+ end
end);
prosody.events.add_handler('pre-jitsi-authentication', function(session)