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: Moves common process_host_module to util.
damencho78cf510c0b75
diff --git a/resources/prosody-plugins/mod_av_moderation_component.lua b/resources/prosody-plugins/mod_av_moderation_component.luaindex b7903c0903..8a657097c2 100644--- a/resources/prosody-plugins/mod_av_moderation_component.lua+++ b/resources/prosody-plugins/mod_av_moderation_component.lua@@ -1,7 +1,9 @@-local get_room_by_name_and_subdomain = module:require 'util'.get_room_by_name_and_subdomain;-local is_healthcheck_room = module:require 'util'.is_healthcheck_room;-local internal_room_jid_match_rewrite = module:require "util".internal_room_jid_match_rewrite;-local room_jid_match_rewrite = module:require "util".room_jid_match_rewrite;+local util = module:require 'util';+local get_room_by_name_and_subdomain = util.get_room_by_name_and_subdomain;+local is_healthcheck_room = util.is_healthcheck_room;+local internal_room_jid_match_rewrite = util.internal_room_jid_match_rewrite;+local room_jid_match_rewrite = util.room_jid_match_rewrite;+local process_host_module = util.process_host_module;local array = require "util.array";local json = require 'util.json';local st = require 'util.stanza';@@ -300,22 +302,8 @@ end-- we will receive messages from the clientsmodule:hook('message/host', on_message);--- executed on every host added internally in prosody, including components-function process_host(host)- if host == muc_component_host then -- the conference muc component- module:log('info','Hook to muc events on %s', host);-- local muc_module = module:context(host);- muc_module:hook('muc-occupant-joined', occupant_joined, -2); -- make sure it runs after allowners or similar- muc_module:hook('muc-set-affiliation', occupant_affiliation_changed, -1);- end-end--if prosody.hosts[muc_component_host] == nil then- module:log('info', 'No muc component found, will listen for it: %s', muc_component_host);-- -- when a host or component is added- prosody.events.add_handler('host-activated', process_host);-else- process_host(muc_component_host);-end+process_host_module(muc_component_host, function(host_module, host)+ module:log('info','Hook to muc events on %s', host);+ host_module:hook('muc-occupant-joined', occupant_joined, -2); -- make sure it runs after allowners or similar+ host_module:hook('muc-set-affiliation', occupant_affiliation_changed, -1);+end);diff --git a/resources/prosody-plugins/mod_filter_iq_rayo.lua b/resources/prosody-plugins/mod_filter_iq_rayo.luaindex 81f7c0f920..2c7324b5d4 100644--- a/resources/prosody-plugins/mod_filter_iq_rayo.lua+++ b/resources/prosody-plugins/mod_filter_iq_rayo.lua@@ -7,6 +7,7 @@ local room_jid_match_rewrite = util.room_jid_match_rewrite;local is_feature_allowed = util.is_feature_allowed;local get_room_from_jid = util.get_room_from_jid;local is_healthcheck_room = util.is_healthcheck_room;+local process_host_module = util.process_host_module;local jid_bare = require "util.jid".bare;local sessions = prosody.full_sessions;@@ -195,24 +196,6 @@ endmodule:hook_global('config-reloaded', load_config);--- process a host module directly if loaded or hooks to wait for its load-function process_host_module(name, callback)- local function process_host(host)- if host == name then- callback(module:context(host), host);- end- end-- if prosody.hosts[name] == nil then- module:log('debug', 'No host/component found, will wait for it: %s', name)-- -- when a host or component is added- prosody.events.add_handler('host-activated', process_host);- else- process_host(name);- end-end-function process_set_affiliation(event)local actor, affiliation, jid, previous_affiliation, room= event.actor, event.affiliation, event.jid, event.previous_affiliation, event.room;diff --git a/resources/prosody-plugins/mod_muc_breakout_rooms.lua b/resources/prosody-plugins/mod_muc_breakout_rooms.luaindex 3f79ed5766..d255dc7d2a 100644--- a/resources/prosody-plugins/mod_muc_breakout_rooms.lua+++ b/resources/prosody-plugins/mod_muc_breakout_rooms.lua@@ -36,6 +36,7 @@ local uuid_gen = require 'util.uuid'.generate;local util = module:require 'util';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 BREAKOUT_ROOMS_IDENTITY_TYPE = 'breakout_rooms';-- Available breakout room functionality@@ -478,25 +479,6 @@ end-- Module operations--- process a host module directly if loaded or hooks to wait for its load-function process_host_module(name, callback)- local function process_host(host)- if host == name then- callback(module:context(host), host);- end- end-- if prosody.hosts[name] == nil then- module:log('debug', 'No host/component found, will wait for it: %s', name)-- -- when a host or component is added- prosody.events.add_handler('host-activated', process_host);- else- process_host(name);- end-end---- operates on already loaded breakout rooms muc modulefunction process_breakout_rooms_muc_loaded(breakout_rooms_muc, host_module)module:log('debug', 'Breakout rooms muc loaded');diff --git a/resources/prosody-plugins/mod_muc_flip.lua b/resources/prosody-plugins/mod_muc_flip.luaindex 8d1a244706..628528a2ac 100644--- a/resources/prosody-plugins/mod_muc_flip.lua+++ b/resources/prosody-plugins/mod_muc_flip.lua@@ -5,6 +5,7 @@local oss_util = module:require "util";local is_healthcheck_room = oss_util.is_healthcheck_room;+local process_host_module = oss_util.process_host_module;local um_is_admin = require "core.usermanager".is_admin;local inspect = require('inspect');local jid_bare = require "util.jid".bare;@@ -188,24 +189,6 @@ function process_lobby_muc_loaded(lobby_muc, host_module)lobby_host = module:context(host_module);end--- process a host module directly if loaded or hooks to wait for its load-function process_host_module(name, callback)- local function process_host(host)- if host == name then- callback(module:context(host), host);- end- end-- if prosody.hosts[name] == nil then- module:log('debug', 'No host/component found, will wait for it: %s', name)-- -- when a host or component is added- prosody.events.add_handler('host-activated', process_host);- else- process_host(name);- end-end--- process or waits to process the lobby muc componentprocess_host_module(lobby_muc_component_config, function(host_module, host)-- lobby muc component createddiff --git a/resources/prosody-plugins/mod_muc_jigasi_invite.lua b/resources/prosody-plugins/mod_muc_jigasi_invite.luaindex 286c6ccd33..3a761fadb4 100644--- a/resources/prosody-plugins/mod_muc_jigasi_invite.lua+++ b/resources/prosody-plugins/mod_muc_jigasi_invite.lua@@ -9,6 +9,7 @@ local st = require("util.stanza");local json = require "util.json";local util = module:require "util";local async_handler_wrapper = util.async_handler_wrapper;+local process_host_module = util.process_host_module;local muc_domain_base = module:get_option_string("muc_mapper_domain_base");@@ -167,24 +168,6 @@ module:provides("http", {};});--- process a host module directly if loaded or hooks to wait for its load-function process_host_module(name, callback)- local function process_host(host)- if host == name then- callback(module:context(host), host);- end- end-- if prosody.hosts[name] == nil then- module:log('info', 'No host/component found, will wait for it: %s', name)-- -- when a host or component is added- prosody.events.add_handler('host-activated', process_host);- else- process_host(name);- end-end-process_host_module(muc_domain, function(_, host)local muc_module = prosody.hosts[host].modules.muc;if muc_module thendiff --git a/resources/prosody-plugins/mod_muc_lobby_rooms.lua b/resources/prosody-plugins/mod_muc_lobby_rooms.luaindex d064410ee7..73cfd2c9c0 100644--- a/resources/prosody-plugins/mod_muc_lobby_rooms.lua+++ b/resources/prosody-plugins/mod_muc_lobby_rooms.lua@@ -46,6 +46,7 @@ local ends_with = util.ends_with;local get_room_by_name_and_subdomain = util.get_room_by_name_and_subdomain;local is_healthcheck_room = util.is_healthcheck_room;local presence_check_status = util.presence_check_status;+local process_host_module = util.process_host_module;local main_muc_component_config = module:get_option_string('main_muc');if main_muc_component_config == nil then@@ -234,24 +235,6 @@ function destroy_lobby_room(room, newjid, message)endend--- process a host module directly if loaded or hooks to wait for its load-function process_host_module(name, callback)- local function process_host(host)- if host == name then- callback(module:context(host), host);- end- end-- if prosody.hosts[name] == nil then- module:log('debug', 'No host/component found, will wait for it: %s', name)-- -- when a host or component is added- prosody.events.add_handler('host-activated', process_host);- else- process_host(name);- end-end--- operates on already loaded lobby muc modulefunction process_lobby_muc_loaded(lobby_muc, host_module)module:log('debug', 'Lobby muc loaded');diff --git a/resources/prosody-plugins/mod_muc_password_check.lua b/resources/prosody-plugins/mod_muc_password_check.luaindex 0f8bfa7049..5f948a8e7a 100644--- a/resources/prosody-plugins/mod_muc_password_check.lua+++ b/resources/prosody-plugins/mod_muc_password_check.lua@@ -6,6 +6,7 @@ local json = require "util.json";local util = module:require "util";local async_handler_wrapper = util.async_handler_wrapper;local starts_with = util.starts_with;+local process_host_module = util.process_host_module;local token_util = module:require "token/util".new(module);-- option to enable/disable room API token verifications@@ -160,24 +161,6 @@ function handle_get_room_password (event)return GET_response;end--- process a host module directly if loaded or hooks to wait for its load-function process_host_module(name, callback)- local function process_host(host)- if host == name then- callback(module:context(host), host);- end- end-- if prosody.hosts[name] == nil then- module:log('debug', 'No host/component found, will wait for it: %s', name)-- -- when a host or component is added- prosody.events.add_handler('host-activated', process_host);- else- process_host(name);- end-end-process_host_module(muc_domain_base, function(host_module, host)module:log("info","Adding http handler for /room-info on %s", host_module.host);host_module:depends("http");diff --git a/resources/prosody-plugins/mod_muc_wait_for_host.lua b/resources/prosody-plugins/mod_muc_wait_for_host.luaindex 78de5bb6a3..042bf9e4aa 100644--- a/resources/prosody-plugins/mod_muc_wait_for_host.lua+++ b/resources/prosody-plugins/mod_muc_wait_for_host.lua@@ -11,6 +11,7 @@ local jid = require 'util.jid';local util = module:require "util";local is_healthcheck_room = util.is_healthcheck_room;local is_moderated = util.is_moderated;+local process_host_module = util.process_host_module;local disable_auto_owners = module:get_option_boolean('wait_for_host_disable_auto_owners', false);@@ -94,24 +95,6 @@ module:hook('muc-occupant-pre-join', function (event)endend);--- process a host module directly if loaded or hooks to wait for its load-function process_host_module(name, callback)- local function process_host(host)- if host == name then- callback(module:context(host), host);- end- end-- if prosody.hosts[name] == nil then- module:log('debug', 'No host/component found, will wait for it: %s', name)-- -- when a host or component is added- prosody.events.add_handler('host-activated', process_host);- else- process_host(name);- end-end-process_host_module(lobby_muc_component_config, function(host_module, host)-- lobby muc component createdmodule:log('info', 'Lobby component loaded %s', host);diff --git a/resources/prosody-plugins/mod_reservations.lua b/resources/prosody-plugins/mod_reservations.luaindex 84abfbf48f..bc6229bb46 100644--- a/resources/prosody-plugins/mod_reservations.lua+++ b/resources/prosody-plugins/mod_reservations.lua@@ -77,9 +77,11 @@ local st = require "util.stanza";local timer = require 'util.timer';local datetime = require 'util.datetime';-local get_room_from_jid = module:require "util".get_room_from_jid;-local is_healthcheck_room = module:require "util".is_healthcheck_room;-local room_jid_match_rewrite = module:require "util".room_jid_match_rewrite;+local util = module:require "util";+local get_room_from_jid = util.get_room_from_jid;+local is_healthcheck_room = util.is_healthcheck_room;+local room_jid_match_rewrite = util.room_jid_match_rewrite;+local process_host_module = util.process_host_module;local api_prefix = module:get_option("reservations_api_prefix");local api_headers = module:get_option("reservations_api_headers");@@ -677,27 +679,17 @@ local function room_pre_create(event)endend--function process_host(host)- if host == muc_component_host then -- the conference muc component+process_host_module(muc_component_host, function(host_module, host)module:log("info", "Hook to muc-room-destroyed on %s", host);- module:context(host):hook("muc-room-destroyed", room_destroyed, -1);+ host_module:hook("muc-room-destroyed", room_destroyed, -1);if max_occupants_enabled or password_support_enabled thenmodule:log("info", "Hook to muc-room-created on %s (max_occupants or password integration enabled)", host);- module:context(host):hook("muc-room-created", room_created);+ host_module:hook("muc-room-created", room_created);endif lobby_support_enabled thenmodule:log("info", "Hook to muc-room-pre-create on %s (lobby integration enabled)", host);- module:context(host):hook("muc-room-pre-create", room_pre_create);+ host_module:hook("muc-room-pre-create", room_pre_create);end- end-end--if prosody.hosts[muc_component_host] == nil then- module:log("info", "No muc component found, will listen for it: %s", muc_component_host)- prosody.events.add_handler("host-activated", process_host);-else- process_host(muc_component_host);-end+end);diff --git a/resources/prosody-plugins/mod_room_metadata_component.lua b/resources/prosody-plugins/mod_room_metadata_component.luaindex ffb1e05fa4..70fbae812c 100644--- a/resources/prosody-plugins/mod_room_metadata_component.lua+++ b/resources/prosody-plugins/mod_room_metadata_component.lua@@ -19,6 +19,7 @@ local util = module:require 'util';local is_healthcheck_room = util.is_healthcheck_room;local get_room_from_jid = util.get_room_from_jid;local room_jid_match_rewrite = util.room_jid_match_rewrite;+local process_host_module = util.process_host_module;local COMPONENT_IDENTITY_TYPE = 'room_metadata';local FORM_KEY = 'muc#roominfo_jitsimetadata';@@ -145,24 +146,6 @@ end-- Module operations--- process a host module directly if loaded or hooks to wait for its load-function process_host_module(name, callback)- local function process_host(host)- if host == name then- callback(module:context(host), host);- end- end-- if prosody.hosts[name] == nil then- module:log('debug', 'No host/component found, will wait for it: %s', name)-- -- when a host or component is added- prosody.events.add_handler('host-activated', process_host);- else- process_host(name);- end-end--- handle messages to this componentmodule:hook("message/host", on_message);diff --git a/resources/prosody-plugins/mod_speakerstats_component.lua b/resources/prosody-plugins/mod_speakerstats_component.luaindex 54029147f3..9c5bce3b65 100644--- a/resources/prosody-plugins/mod_speakerstats_component.lua+++ b/resources/prosody-plugins/mod_speakerstats_component.lua@@ -1,6 +1,8 @@-local get_room_from_jid = module:require "util".get_room_from_jid;-local room_jid_match_rewrite = module:require "util".room_jid_match_rewrite;-local is_healthcheck_room = module:require "util".is_healthcheck_room;+local util = module:require "util";+local get_room_from_jid = util.get_room_from_jid;+local room_jid_match_rewrite = util.room_jid_match_rewrite;+local is_healthcheck_room = util.is_healthcheck_room;+local process_host_module = util.process_host_module;local jid_resource = require "util.jid".resource;local ext_events = module:require "ext_events"local st = require "util.stanza";@@ -337,24 +339,6 @@ function process_breakout_muc_loaded(breakout_muc, host_module)host_module:hook("muc-room-destroyed", room_destroyed, -1);end--- process a host module directly if loaded or hooks to wait for its load-function process_host_module(name, callback)- local function process_host(host)- if host == name then- callback(module:context(host), host);- end- end-- if prosody.hosts[name] == nil then- module:log('debug', 'No host/component found, will wait for it: %s', name)-- -- when a host or component is added- prosody.events.add_handler('host-activated', process_host);- else- process_host(name);- end-end--- process or waits to process the conference muc componentprocess_host_module(muc_component_host, function(host_module, host)module:log('info', 'Conference component loaded %s', host);diff --git a/resources/prosody-plugins/mod_visitors.lua b/resources/prosody-plugins/mod_visitors.luaindex c8ca49f78c..3377f566ac 100644--- a/resources/prosody-plugins/mod_visitors.lua+++ b/resources/prosody-plugins/mod_visitors.lua@@ -13,6 +13,7 @@ local jid = require 'util.jid';local new_id = require 'util.id'.medium;local util = module:require 'util';local presence_check_status = util.presence_check_status;+local process_host_module = util.process_host_module;local um_is_admin = require 'core.usermanager'.is_admin;local function is_admin(jid)@@ -175,24 +176,6 @@ module:hook('presence/full', function(event)endend, 900);--- process a host module directly if loaded or hooks to wait for its load-function process_host_module(name, callback)- local function process_host(host)- if host == name then- callback(module:context(host), host);- end- end-- if prosody.hosts[name] == nil then- module:log('debug', 'No host/component found, will wait for it: %s', name)-- -- when a host or component is added- prosody.events.add_handler('host-activated', process_host);- else- process_host(name);- end-end-process_host_module(main_muc_component_config, function(host_module, host)-- detects presence change in a main participant and propagate it to the used visitor nodeshost_module:hook('muc-occupant-pre-change', function (event)diff --git a/resources/prosody-plugins/mod_visitors_component.lua b/resources/prosody-plugins/mod_visitors_component.luaindex 293c4e2c9f..3357d03077 100644--- a/resources/prosody-plugins/mod_visitors_component.lua+++ b/resources/prosody-plugins/mod_visitors_component.lua@@ -11,6 +11,7 @@ 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 is_vpaas = util.is_vpaas;local is_sip_jibri_join = util.is_sip_jibri_join;+local process_host_module = util.process_host_module;local new_id = require 'util.id'.medium;local um_is_admin = require 'core.usermanager'.is_admin;local json = require 'util.json';@@ -262,24 +263,6 @@ endmodule:hook('iq/host', stanza_handler, 10);- --process a host module directly if loaded or hooks to wait for its load-function process_host_module(name, callback)- local function process_host(host)- if host == name then- callback(module:context(host), host);- end- end-- if prosody.hosts[name] == nil then- module:log('debug', 'No host/component found, will wait for it: %s', name)-- -- when a host or component is added- prosody.events.add_handler('host-activated', process_host);- else- process_host(name);- end-end-process_host_module(muc_domain_prefix..'.'..muc_domain_base, function(host_module, host)-- if visitor mode is started, then you are not allowed to join without request/response exchange of iqs -> deny access-- check list of allowed jids for the roomdiff --git a/resources/prosody-plugins/util.lib.lua b/resources/prosody-plugins/util.lib.luaindex bb78a558cf..1cd927bb57 100644--- a/resources/prosody-plugins/util.lib.lua+++ b/resources/prosody-plugins/util.lib.lua@@ -490,6 +490,26 @@ function is_sip_jibri_join(stanza)return falseend+-- process a host module directly if loaded or hooks to wait for its load+function process_host_module(name, callback)+ local function process_host(host)++ if host == name then+ callback(module:context(host), host);+ end+ end++ if prosody.hosts[name] == nil then+ module:log('info', 'No host/component found, will wait for it: %s', name)++ -- when a host or component is added+ prosody.events.add_handler('host-activated', process_host);+ else+ process_host(name);+ end+end++return {OUTBOUND_SIP_JIBRI_PREFIX = OUTBOUND_SIP_JIBRI_PREFIX;@@ -506,6 +526,7 @@ return {get_sip_jibri_email_prefix = get_sip_jibri_email_prefix;async_handler_wrapper = async_handler_wrapper;presence_check_status = presence_check_status;+ process_host_module = process_host_module;room_jid_match_rewrite = room_jid_match_rewrite;room_jid_split_subdomain = room_jid_split_subdomain;internal_room_jid_match_rewrite = internal_room_jid_match_rewrite;