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
Clean up prosody modules with some extra checks (#14020)
Дамян Минков0e55cbbda676
diff --git a/resources/prosody-plugins/mod_fmuc.lua b/resources/prosody-plugins/mod_fmuc.luaindex 4e210bef46..1aceb58480 100644--- a/resources/prosody-plugins/mod_fmuc.lua+++ b/resources/prosody-plugins/mod_fmuc.lua@@ -292,10 +292,12 @@ end);module:hook('muc-occupant-groupchat', function(event)local occupant, room, stanza = event.occupant, event.room, event.stanza;local from = stanza.attr.from;- local occupant_host = jid.host(occupant.bare_jid);+ local occupant_host;-- if there is no occupant this is a message from main, probably coming from other vnodeif occupant then+ occupant_host = jid.host(occupant.bare_jid);+-- we manage nick only for visitorsif occupant_host ~= main_domain then-- add to message stanza display name for the visitordiff --git a/resources/prosody-plugins/mod_muc_allowners.lua b/resources/prosody-plugins/mod_muc_allowners.luaindex cde35d0452..b8df9ff832 100644--- a/resources/prosody-plugins/mod_muc_allowners.lua+++ b/resources/prosody-plugins/mod_muc_allowners.lua@@ -136,7 +136,7 @@ function filter_admin_set_query(event)local _aff = item.attr.affiliation;-- if it is a moderated room we skip it- if is_moderated(room.jid) then+ if room and is_moderated(room.jid) thenreturn nil;enddiff --git a/resources/prosody-plugins/mod_muc_breakout_rooms.lua b/resources/prosody-plugins/mod_muc_breakout_rooms.luaindex a407b3b94d..b3557c66d6 100644--- a/resources/prosody-plugins/mod_muc_breakout_rooms.lua+++ b/resources/prosody-plugins/mod_muc_breakout_rooms.lua@@ -342,12 +342,11 @@ endfunction on_breakout_room_pre_create(event)local breakout_room = event.room;local main_room, main_room_jid = get_main_room(breakout_room.jid);- local name = main_room._data.breakout_rooms[breakout_room.jid];-- Only allow existent breakout rooms to be started.-- Authorisation of breakout rooms is done by their random uuid name- if main_room and main_room._data.breakout_rooms and name then- breakout_room:set_subject(breakout_room.jid, name);+ if main_room and main_room._data.breakout_rooms and main_room._data.breakout_rooms[breakout_room.jid] then+ breakout_room:set_subject(breakout_room.jid, main_room._data.breakout_rooms[breakout_room.jid]);elsemodule:log('debug', 'Invalid breakout room %s will not be created.', breakout_room.jid);breakout_room:destroy(main_room_jid, 'Breakout room is invalid.');diff --git a/resources/prosody-plugins/mod_muc_flip.lua b/resources/prosody-plugins/mod_muc_flip.luaindex 34ab2fa978..85b726b1cd 100644--- a/resources/prosody-plugins/mod_muc_flip.lua+++ b/resources/prosody-plugins/mod_muc_flip.lua@@ -62,7 +62,7 @@ module:hook("muc-occupant-pre-join", function(event)module:log("debug", "Bypass lobby invitee %s", occupant_jid)occupant.role = "participant";room:set_affiliation(true, jid_bare(occupant_jid), "member")- room:save();+ room:save_occupant(occupant);end-- bypass password on the flip devicelocal join = stanza:get_child("x", MUC_NS);@@ -111,12 +111,19 @@ end)module:hook("muc-occupant-joined", function(event)local room, occupant = event.room, event.occupant;if is_healthcheck_room(room.jid) or is_admin(occupant.bare_jid) then- return ;+ return;endif room._data.flip_participant_nick and occupant.nick == room._data.flip_participant_nick then-- make joining participant from flip device have the same role and affiliation as for the previous devicelocal kicked_occupant = room:get_occupant_by_nick(room._data.kicked_participant_nick);++ if not kicked_occupant then+ module:log("info", "Kick participant not found, nick %s from main room jid %s",+ room._data.kicked_participant_nick, room.jid)+ return;+ end+local initial_affiliation = room:get_affiliation(kicked_occupant.jid) or "member";module:log("debug", "Transfer affiliation %s to occupant jid %s", initial_affiliation, occupant.jid)room:set_affiliation(true, occupant.bare_jid, initial_affiliation)@@ -129,7 +136,7 @@ module:hook("muc-occupant-joined", function(event)local kicked_participant_node_jid = jid.split(kicked_occupant.jid);module:log("info", "Kick participant jid %s nick %s from main room jid %s", kicked_occupant.jid, room._data.kicked_participant_nick, room.jid)room:set_role(true, room._data.kicked_participant_nick, 'none')- room:save()+ room:save_occupant(occupant);-- Kick participant from the first device from the lobby roomif room._data.lobbyroom thenlocal lobby_room_jid = room._data.lobbyroom;diff --git a/resources/prosody-plugins/mod_muc_lobby_rooms.lua b/resources/prosody-plugins/mod_muc_lobby_rooms.luaindex dc7e2dd3c9..d064410ee7 100644--- a/resources/prosody-plugins/mod_muc_lobby_rooms.lua+++ b/resources/prosody-plugins/mod_muc_lobby_rooms.lua@@ -165,6 +165,12 @@ function filter_stanza(stanza)-- allow messages to or from moderatorlocal lobby_room_jid = jid_bare(stanza.attr.from);local lobby_room = lobby_muc_service.get_room_from_jid(lobby_room_jid);++ if not lobby_room then+ module:log('warn', 'No lobby room found %s', stanza.attr.from);+ return nil;+ end+local is_to_moderator = lobby_room:get_affiliation(stanza.attr.to) == 'owner';local from_occupant = lobby_room:get_occupant_by_nick(stanza.attr.from);@@ -396,7 +402,7 @@ process_host_module(main_muc_component_config, function(host_module, host)if not affiliation or affiliation == 'none' or affiliation == 'member' thenoccupant.role = 'participant';room:set_affiliation(true, invitee_bare_jid, 'member');- room:save();+ room:save_occupant(occupant);return;enddiff --git a/resources/prosody-plugins/mod_speakerstats_component.lua b/resources/prosody-plugins/mod_speakerstats_component.luaindex 04598b82ac..54029147f3 100644--- a/resources/prosody-plugins/mod_speakerstats_component.lua+++ b/resources/prosody-plugins/mod_speakerstats_component.lua@@ -35,15 +35,16 @@ end-- Searches all rooms in the main muc component that holds a breakout room-- caches it if found so we don't search it again+-- we should not cache objects in _data as this is being serialized when calling room:save()local function get_main_room(breakout_room)- if breakout_room._data and breakout_room._data.main_room then- return breakout_room._data.main_room;+ if breakout_room.main_room then+ return breakout_room.main_room;end-- let's search all rooms to find the main roomfor room in main_muc_service.each_room() doif room._data and room._data.breakout_rooms_active and room._data.breakout_rooms[breakout_room.jid] then- breakout_room._data.main_room = room;+ breakout_room.main_room = room;return room;endend@@ -117,7 +118,7 @@ function on_message(event)local from = event.stanza.attr.from;local occupant = room:get_occupant_by_real_jid(from);- if not occupant then+ if not occupant or not room.speakerStats[occupant.jid] thenmodule:log("warn", "No occupant %s found for %s", from, roomAddress);return false;enddiff --git a/resources/prosody-plugins/token/util.lib.lua b/resources/prosody-plugins/token/util.lib.luaindex ab413c85cf..78b2d2e7c9 100644--- a/resources/prosody-plugins/token/util.lib.lua+++ b/resources/prosody-plugins/token/util.lib.lua@@ -17,6 +17,7 @@ local starts_with = main_util.starts_with;local cjson_safe = require 'cjson.safe'local timer = require "util.timer";local async = require "util.async";+local inspect = require 'inspect';local nr_retries = 3;local ssl = require "ssl";@@ -344,7 +345,11 @@ function Util:verify_room(session, room_address)local auth_room = session.jitsi_meet_room;if auth_room then- auth_room = string.lower(auth_room);+ if type(auth_room) == 'string' then+ auth_room = string.lower(auth_room);+ else+ module:log('warn', 'session.jitsi_meet_room not string: %s', inspect(auth_room));+ endendif not self.enableDomainVerification then-- if auth_room is missing, this means user is anonymous (no token for