diff --git a/resources/prosody-plugins/mod_fmuc.lua b/resources/prosody-plugins/mod_fmuc.lua index 89c9872cef..71ce95cd26 100644 --- a/resources/prosody-plugins/mod_fmuc.lua +++ b/resources/prosody-plugins/mod_fmuc.lua @@ -52,11 +52,16 @@ end -- mark all occupants as visitors module:hook('muc-occupant-pre-join', function (event) - local occupant, session = event.occupant, event.origin; + local occupant, room, origin, stanza = event.occupant, event.room, event.origin, event.stanza; local node, host = jid.split(occupant.bare_jid); if host == local_domain then - occupant.role = 'visitor'; + if room._main_room_lobby_enabled then + origin.send(st.error_reply(stanza, 'cancel', 'not-allowed', 'Visitors not allowed while lobby is on!')); + return true; + else + occupant.role = 'visitor'; + end end end, 3); @@ -439,6 +444,12 @@ local function iq_from_main_handler(event) room:set_password(node.attr.password); room._data.meetingId = node.attr.meetingId; + if node.attr.lobby == 'true' then + room._main_room_lobby_enabled = true; + elseif node.attr.lobby == 'false' then + room._main_room_lobby_enabled = false; + end + if fire_jicofo_unlock then -- everything is connected allow participants to join module:fire_event('jicofo-unlock-room', { room = room; fmuc_fired = true; }); diff --git a/resources/prosody-plugins/mod_muc_lobby_rooms.lua b/resources/prosody-plugins/mod_muc_lobby_rooms.lua index b3535d7cea..54105da0e0 100644 --- a/resources/prosody-plugins/mod_muc_lobby_rooms.lua +++ b/resources/prosody-plugins/mod_muc_lobby_rooms.lua @@ -334,11 +334,13 @@ process_host_module(main_muc_component_config, function(host_module, host) if members_only then local lobby_created = attach_lobby_room(room, actor); if lobby_created then + module:fire_event('jitsi-lobby-enabled', { room = room; }); event.status_codes['104'] = true; notify_lobby_enabled(room, actor, true); end elseif room._data.lobbyroom then destroy_lobby_room(room, room.jid); + module:fire_event('jitsi-lobby-disabled', { room = room; }); notify_lobby_enabled(room, actor, false); end end); diff --git a/resources/prosody-plugins/mod_visitors.lua b/resources/prosody-plugins/mod_visitors.lua index 148be429e1..242567a830 100644 --- a/resources/prosody-plugins/mod_visitors.lua +++ b/resources/prosody-plugins/mod_visitors.lua @@ -65,6 +65,7 @@ local function send_visitors_iq(conference_service, room, type) room = jid.join(jid.node(room.jid), conference_service) }) :tag(type, { xmlns = 'jitsi:visitors', password = type ~= 'disconnect' and room:get_password() or '', + lobby = room._data.lobbyroom and 'true' or 'false', meetingId = room._data.meetingId }):up(); @@ -146,8 +147,6 @@ local function disconnect_vnode(event) local conference_service = muc_domain_prefix..'.'..vnode..'.meet.jitsi'; - -- we are counting vnode main participants and we should be clearing it there - -- let's do it here just in case visitors_nodes[room.jid].nodes[conference_service] = nil; send_visitors_iq(conference_service, room, 'disconnect'); @@ -338,5 +337,26 @@ process_host_module(main_muc_component_config, function(host_module, host) end end end -end, -100); -- we want to run last in order to check is the status code 104 + end, -100); -- we want to run last in order to check is the status code 104 +end); + +module:hook('jitsi-lobby-enabled', function(event) + local room = event.room; + if visitors_nodes[room.jid] then + -- we need to update all vnodes + local vnodes = visitors_nodes[room.jid].nodes; + for conference_service in pairs(vnodes) do + send_visitors_iq(conference_service, room, 'update'); + end + end +end); +module:hook('jitsi-lobby-disabled', function(event) +local room = event.room; + if visitors_nodes[room.jid] then + -- we need to update all vnodes + local vnodes = visitors_nodes[room.jid].nodes; + for conference_service in pairs(vnodes) do + send_visitors_iq(conference_service, room, 'update'); + end + end end);