Skip to content

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

fix(visitors): Fixes using table for moderators.

damenchoa3d89ea66f6f
diff --git a/resources/prosody-plugins/mod_visitors_component.lua b/resources/prosody-plugins/mod_visitors_component.lua
index 091829e481..275744f27f 100644
--- a/resources/prosody-plugins/mod_visitors_component.lua
+++ b/resources/prosody-plugins/mod_visitors_component.lua
@@ -13,6 +13,7 @@ local get_room_from_jid = util.get_room_from_jid;
local get_focus_occupant = util.get_focus_occupant;
local get_room_by_name_and_subdomain = util.get_room_by_name_and_subdomain;
local internal_room_jid_match_rewrite = util.internal_room_jid_match_rewrite;
+local table_find = util.table_find;
local is_vpaas = util.is_vpaas;
local is_sip_jibri_join = util.is_sip_jibri_join;
local process_host_module = util.process_host_module;
@@ -87,8 +88,8 @@ local function request_promotion_received(room, from_jid, from_vnode, nick, time
-- means that the user has token and is moderator on visitor node side
or room._data.allModerators
- -- can be used by external modules to set a 'util.set' of multiple moderator ids
- or (room._data.moderators and room._data.moderators:contains(user_id))
+ -- can be used by external modules to set multiple moderator ids (table of values)
+ or table_find(room._data.moderators, user_id)
then
force_promote = true;
end
diff --git a/resources/prosody-plugins/util.lib.lua b/resources/prosody-plugins/util.lib.lua
index 4be8db012b..3ea3e3c8fc 100644
--- a/resources/prosody-plugins/util.lib.lua
+++ b/resources/prosody-plugins/util.lib.lua
@@ -591,6 +591,19 @@ function table_shallow_copy(t)
return t2
end
+local function table_find(tab, val)
+ if not tab then
+ return nil
+ end
+
+ for i, v in ipairs(tab) do
+ if v == val then
+ return i
+ end
+ end
+ return nil
+end
+
-- Splits a string using delimiter
function split_string(str, delimiter)
str = str .. delimiter;
@@ -672,4 +685,5 @@ return {
starts_with = starts_with;
starts_with_one_of = starts_with_one_of;
table_shallow_copy = table_shallow_copy;
+ table_find = table_find;
};