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
feat(metadata): Moves turn information to metadata module.
damencho6633bbf05084
diff --git a/resources/prosody-plugins/mod_jiconop.lua b/resources/prosody-plugins/mod_jiconop.luaindex 1a93e7301d..0472488ab0 100644--- a/resources/prosody-plugins/mod_jiconop.lua+++ b/resources/prosody-plugins/mod_jiconop.lua@@ -1,7 +1,5 @@local st = require "util.stanza";local ext_services = module:depends("external_services");-local get_services = ext_services.get_services;-local services_xml = ext_services.services_xml;-- Jitsi Connection Optimization-- gathers needed information and pushes it with a message to clients@@ -70,8 +68,5 @@ module:hook("resource-bind", function (event)to = session.full_jid; });stanza:add_child(query):up();- --- get turnservers and credentials- stanza:add_child(services_xml(get_services()));-session.send(stanza);end);diff --git a/resources/prosody-plugins/mod_muc_breakout_rooms.lua b/resources/prosody-plugins/mod_muc_breakout_rooms.luaindex 62ed17c0cd..a91e48659d 100644--- a/resources/prosody-plugins/mod_muc_breakout_rooms.lua+++ b/resources/prosody-plugins/mod_muc_breakout_rooms.lua@@ -39,6 +39,7 @@ local internal_room_jid_match_rewrite = util.internal_room_jid_match_rewrite;local is_healthcheck_room = util.is_healthcheck_room;local process_host_module = util.process_host_module;local is_admin = util.is_admin;+local get_occupant_by_real_jid = util.get_occupant_by_real_jid;local BREAKOUT_ROOMS_IDENTITY_TYPE = 'breakout_rooms';-- Available breakout room functionality@@ -319,23 +320,11 @@ function on_message(event)-- check that the participant requesting is a moderator and is an occupant in the roomlocal from = event.stanza.attr.from;- local occupant = room:get_occupant_by_real_jid(from);+ local occupant = get_occupant_by_real_jid(room, from);if not occupant then- -- Check if the participant is in any breakout room.- for breakout_room_jid in pairs(room._data.breakout_rooms or {}) do- local breakout_room = breakout_rooms_muc_service.get_room_from_jid(breakout_room_jid);- if breakout_room then- occupant = breakout_room:get_occupant_by_real_jid(from);- if occupant then- break;- end- end- end- if not occupant then- module:log('warn', 'No occupant %s found for %s', from, room.jid);- return false;- end+ module:log('warn', 'No occupant %s found for %s', from, room.jid);+ return false;endif occupant.role ~= 'moderator' thendiff --git a/resources/prosody-plugins/mod_polls_component.lua b/resources/prosody-plugins/mod_polls_component.luaindex 514ad06ff4..6143f701c0 100644--- a/resources/prosody-plugins/mod_polls_component.lua+++ b/resources/prosody-plugins/mod_polls_component.lua@@ -13,6 +13,7 @@ local muc = module:depends("muc");local NS_NICK = 'http://jabber.org/protocol/nick';local get_room_by_name_and_subdomain = util.get_room_by_name_and_subdomain;local get_room_from_jid = util.get_room_from_jid;+local get_occupant_by_real_jid = util.get_occupant_by_real_jid;local is_healthcheck_room = util.is_healthcheck_room;local room_jid_match_rewrite = util.room_jid_match_rewrite;local internal_room_jid_match_rewrite = util.internal_room_jid_match_rewrite;@@ -146,25 +147,9 @@ endreturn;end- occupant = main_room:get_occupant_by_real_jid(occupant_jid);-- if main_room._data.breakout_rooms_active and not occupant then- -- let's find is this participant in the main room or in some breakout room- -- not in main room, let's check breakout rooms- for breakout_room_jid, subject in pairs(main_room._data.breakout_rooms or {}) do- local breakout_room = get_room_from_jid(breakout_room_jid);-- if breakout_room then- occupant = breakout_room:get_occupant_by_real_jid(occupant_jid);- if occupant then- room = breakout_room;- break;- end- end- end- else- room = main_room;- end+ local found_room;+ occupant, found_room = get_occupant_by_real_jid(main_room, occupant_jid);+ room = found_room or main_room;if not occupant thenmodule:log('error', 'Occupant sending poll msg %s was not found in room %s', occupant_jid, room.jid)diff --git a/resources/prosody-plugins/mod_room_metadata_component.lua b/resources/prosody-plugins/mod_room_metadata_component.luaindex 8cfb42ba12..6e27b0ca10 100644--- a/resources/prosody-plugins/mod_room_metadata_component.lua+++ b/resources/prosody-plugins/mod_room_metadata_component.lua@@ -20,6 +20,12 @@ local process_host_module = util.process_host_module;local table_shallow_copy = util.table_shallow_copy;local table_add = util.table_add;local table_equals = util.table_equals;+local get_room_by_name_and_subdomain = util.get_room_by_name_and_subdomain;+local get_occupant_by_real_jid = util.get_occupant_by_real_jid;++local dt = require "prosody.util.datetime";+local ext_services = module:depends("external_services");+local get_services = ext_services.get_services;local MUC_NS = 'http://jabber.org/protocol/muc';local COMPONENT_IDENTITY_TYPE = 'room_metadata';@@ -39,6 +45,8 @@ if not main_virtual_host thenendlocal breakout_rooms_component_host = module:get_option_string('breakout_rooms_component');+-- TODO: flip default once mobile clients update to latest ljm that supports transition of turn data in metadata+local extdisco_occpuant_check = module:get_option_boolean('extdisco_occpuant_check', false);module:log("info", "Starting room metadata for %s", muc_component_host);@@ -72,9 +80,9 @@ function broadcastMetadata(room, json_msg)endend-function send_metadata(occupant, room, json_msg)+function send_metadata(occupant, room, json_msg, include_services)if not json_msg or is_admin(occupant.bare_jid) then- local metadata_to_send = room.jitsiMetadata or {};+ local metadata_to_send = table_shallow_copy(room.jitsiMetadata) or {};-- we want to send the main meeting participants only to jicofoif is_admin(occupant.bare_jid) then@@ -90,11 +98,25 @@ function send_metadata(occupant, room, json_msg)moderators:append(room._data.moderators);end- metadata_to_send = table_shallow_copy(metadata_to_send);metadata_to_send.participants = participants;metadata_to_send.moderators = moderators;module:log('info', 'Sending metadata to jicofo room=%s,meeting_id=%s', room.jid, room._data.meetingId);+ elseif include_services then+ metadata_to_send.services = {};++ for _, srv in ipairs(get_services()) do+ table.insert(metadata_to_send.services, {+ type = srv.type;+ transport = srv.transport;+ host = srv.host;+ port = srv.port and string.format('%d', srv.port) or nil;+ username = srv.username;+ password = srv.password;+ expires = srv.expires and dt.datetime(srv.expires) or nil;+ restricted = srv.restricted and '1' or nil;+ });+ endendjson_msg = getMetadataJSON(room, metadata_to_send);@@ -333,6 +355,36 @@ if breakout_rooms_component_host thenend);end+-- checks whether the event is from an occupant of the room specified in the session,+-- if not, it returns an error and stops the processing of the event+local function check_occupant(event)+ local origin, stanza = event.origin, event.stanza;++ local room_name = origin.jitsi_web_query_room;+ if not room_name then+ module:log('warn', 'No room in session: %s', origin.full_jid);+ origin.send(st.error_reply(stanza, 'auth', 'forbidden'));+ return true;+ end++ local subdomain = origin.jitsi_web_query_prefix or '';+ local room = get_room_by_name_and_subdomain(room_name, subdomain);+ if not room then+ module:log('warn', 'Room not found (%s/%s) for %s', subdomain, room_name, origin.full_jid);+ origin.send(st.error_reply(stanza, 'auth', 'forbidden'));+ return true;+ end++ local from = stanza.attr.from or origin.full_jid;+ local occupant = get_occupant_by_real_jid(room, from);++ if not occupant then+ module:log('warn', '%s not an occupant of %s/%s', from, subdomain, room_name);+ origin.send(st.error_reply(stanza, 'auth', 'forbidden'));+ return true;+ end+end+-- Send a message update for metadata before sending the first self presencefunction filter_stanza(stanza, session)if not stanza.attr or not stanza.attr.to or stanza.name ~= 'presence' or stanza.attr.type == 'unavailable' then@@ -369,7 +421,7 @@ function filter_stanza(stanza, session)room.sent_initial_metadata[bare_to] = true;- send_metadata(occupant, room);+ send_metadata(occupant, room, nil, true);return stanza;end@@ -383,7 +435,16 @@ endfilters.add_filter_hook(filter_session);process_host_module(main_virtual_host, function(host_module)- module:context(host_module.host):fire_event('jitsi-add-identity', {+ local main_host_module = module:context(host_module.host);+ main_host_module:fire_event('jitsi-add-identity', {name = 'room_metadata'; host = module.host;});++ if extdisco_occpuant_check then+ -- Hook at priority 100 so we run before mod_external_services (default priority 0) for both XEP-0215 v2 and legacy v1.+ main_host_module:hook('iq-get/host/urn:xmpp:extdisco:2:services', check_occupant, 100);+ main_host_module:hook('iq-get/host/urn:xmpp:extdisco:2:service', check_occupant, 100);+ main_host_module:hook('iq-get/host/urn:xmpp:extdisco:1:services', check_occupant, 100);+ main_host_module:hook('iq-get/host/urn:xmpp:extdisco:1:service', check_occupant, 100);+ endend);diff --git a/resources/prosody-plugins/util.lib.lua b/resources/prosody-plugins/util.lib.luaindex 308e1584cf..984940c1f7 100644--- a/resources/prosody-plugins/util.lib.lua+++ b/resources/prosody-plugins/util.lib.lua@@ -157,6 +157,32 @@ function get_room_by_name_and_subdomain(room_name, subdomain)return get_room_from_jid(room_address);end+-- Returns the occupant and the room (main or one of its active breakout rooms)+-- where the given real full JID is found. Returns nil, nil if not found anywhere.+-- @param room the main room object+-- @param real_jid the full real JID to look up+-- @return occupant, found_room+function get_occupant_by_real_jid(room, real_jid)+ local occupant = room:get_occupant_by_real_jid(real_jid);+ if occupant then+ return occupant, room;+ end++ if room._data.breakout_rooms_active then+ for breakout_room_jid in pairs(room._data.breakout_rooms or {}) do+ local breakout_room = get_room_from_jid(breakout_room_jid);+ if breakout_room then+ occupant = breakout_room:get_occupant_by_real_jid(real_jid);+ if occupant then+ return occupant, breakout_room;+ end+ end+ end+ end++ return nil, nil;+end+function async_handler_wrapper(event, handler)if not have_async thenmodule:log("error", "requires a version of Prosody with util.async");@@ -722,6 +748,7 @@ return {get_ip = get_ip;get_room_from_jid = get_room_from_jid;get_room_by_name_and_subdomain = get_room_by_name_and_subdomain;+ get_occupant_by_real_jid = get_occupant_by_real_jid;get_sip_jibri_email_prefix = get_sip_jibri_email_prefix;async_handler_wrapper = async_handler_wrapper;presence_check_status = presence_check_status;