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: Fixes wait for host to respect moderated tenants.
damencho1f8e3fe26fd5
diff --git a/resources/prosody-plugins/mod_muc_allowners.lua b/resources/prosody-plugins/mod_muc_allowners.luaindex c4be39d10c..a277300f7c 100644--- a/resources/prosody-plugins/mod_muc_allowners.lua+++ b/resources/prosody-plugins/mod_muc_allowners.lua@@ -6,18 +6,14 @@ local st = require "util.stanza";local um_is_admin = require "core.usermanager".is_admin;local util = module:require "util";local is_healthcheck_room = util.is_healthcheck_room;-local extract_subdomain = util.extract_subdomain;+local is_moderated = util.is_moderated;local get_room_from_jid = util.get_room_from_jid;local presence_check_status = util.presence_check_status;local MUC_NS = 'http://jabber.org/protocol/muc';-local moderated_subdomains;-local moderated_rooms;local disable_revoke_owners;local function load_config()- moderated_subdomains = module:get_option_set("allowners_moderated_subdomains", {})- moderated_rooms = module:get_option_set("allowners_moderated_rooms", {})disable_revoke_owners = module:get_option_boolean("allowners_disable_revoke_owners", false);endload_config();@@ -31,32 +27,6 @@ end-- have length of 1local joining_moderator_participants = {};--- Checks whether the jid is moderated, the room name is in moderated_rooms--- or if the subdomain is in the moderated_subdomains--- @return returns on of the:--- -> false--- -> true, room_name, subdomain--- -> true, room_name, nil (if no subdomain is used for the room)-local function is_moderated(room_jid)- if moderated_subdomains:empty() and moderated_rooms:empty() then- return false;- end-- local room_node = jid.node(room_jid);- -- parses bare room address, for multidomain expected format is:- -- [subdomain][email protected]- local target_subdomain, target_room_name = extract_subdomain(room_node);- if target_subdomain then- if moderated_subdomains:contains(target_subdomain) then- return true, target_room_name, target_subdomain;- end- elseif moderated_rooms:contains(room_node) then- return true, room_node, nil;- end-- return false;-end-module:hook("muc-occupant-pre-join", function (event)local room, occupant = event.room, event.occupant;@@ -82,9 +52,9 @@ module:hook("muc-occupant-pre-join", function (event)-- FIX ME: luacheck warning 581-- not (x == y)' can be replaced by 'x ~= y' (if neither side is a table or NaN)- if not (subdomain == session.jitsi_meet_context_group) then+ if not (subdomain == session.jitsi_meet_domain) thenmodule:log('debug', 'skip allowners for auth user and non matching room subdomain: %s, jwt subdomain: %s',- subdomain, session.jitsi_meet_context_group);+ subdomain, session.jitsi_meet_domain);return;endenddiff --git a/resources/prosody-plugins/mod_muc_wait_for_host.lua b/resources/prosody-plugins/mod_muc_wait_for_host.luaindex fe0fcc9f2c..78de5bb6a3 100644--- a/resources/prosody-plugins/mod_muc_wait_for_host.lua+++ b/resources/prosody-plugins/mod_muc_wait_for_host.lua@@ -8,7 +8,9 @@-- This module depends on mod_persistent_lobby.local um_is_admin = require 'core.usermanager'.is_admin;local jid = require 'util.jid';-local is_healthcheck_room = module:require 'util'.is_healthcheck_room;+local util = module:require "util";+local is_healthcheck_room = util.is_healthcheck_room;+local is_moderated = util.is_moderated;local disable_auto_owners = module:get_option_boolean('wait_for_host_disable_auto_owners', false);@@ -29,9 +31,12 @@ local lobby_host;if not disable_auto_owners thenmodule:hook('muc-occupant-joined', function (event)local room, occupant, session = event.room, event.occupant, event.origin;+ local is_moderated_room = is_moderated(room.jid);-- for jwt authenticated and username and password authenticated- if session.auth_token or (session.username and jid.host(occupant.bare_jid) == muc_domain_base) then+ -- only if it is not a moderated room+ if not is_moderated_room and+ (session.auth_token or (session.username and jid.host(occupant.bare_jid) == muc_domain_base)) thenroom:set_affiliation(true, occupant.bare_jid, 'owner');endend, 2);diff --git a/resources/prosody-plugins/util.lib.lua b/resources/prosody-plugins/util.lib.luaindex 9608120467..3c8898537b 100644--- a/resources/prosody-plugins/util.lib.lua+++ b/resources/prosody-plugins/util.lib.lua@@ -30,6 +30,9 @@ local split_subdomain_cache = cache.new(1000);local extract_subdomain_cache = cache.new(1000);local internal_room_jid_cache = cache.new(1000);+local moderated_subdomains = module:get_option_set("allowners_moderated_subdomains", {})+local moderated_rooms = module:get_option_set("allowners_moderated_rooms", {})+-- Utility function to split room JID to include room name and subdomain-- (e.g. from [email protected]/res returns (room1, example.com, res, foo))local function room_jid_split_subdomain(room_jid)@@ -388,10 +391,37 @@ local function get_focus_occupant(room)return room:get_occupant_by_nick(room.jid..'/focus');end+-- Checks whether the jid is moderated, the room name is in moderated_rooms+-- or if the subdomain is in the moderated_subdomains+-- @return returns on of the:+-- -> false+-- -> true, room_name, subdomain+-- -> true, room_name, nil (if no subdomain is used for the room)+function is_moderated(room_jid)+ if moderated_subdomains:empty() and moderated_rooms:empty() then+ return false;+ end++ local room_node = jid.node(room_jid);+ -- parses bare room address, for multidomain expected format is:+ -- [subdomain][email protected]+ local target_subdomain, target_room_name = extract_subdomain(room_node);+ if target_subdomain then+ if moderated_subdomains:contains(target_subdomain) then+ return true, target_room_name, target_subdomain;+ end+ elseif moderated_rooms:contains(room_node) then+ return true, room_node, nil;+ end++ return false;+end+return {extract_subdomain = extract_subdomain;is_feature_allowed = is_feature_allowed;is_healthcheck_room = is_healthcheck_room;+ is_moderated = is_moderated;get_focus_occupant = get_focus_occupant;get_room_from_jid = get_room_from_jid;get_room_by_name_and_subdomain = get_room_by_name_and_subdomain;