Skip to content

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

feat(prosody): Simplifies modules that need to add identity.

damencho93bc4019adfd
diff --git a/doc/debian/jitsi-meet-prosody/prosody.cfg.lua-jvb.example b/doc/debian/jitsi-meet-prosody/prosody.cfg.lua-jvb.example
index d794391057..7af04711f5 100644
--- a/doc/debian/jitsi-meet-prosody/prosody.cfg.lua-jvb.example
+++ b/doc/debian/jitsi-meet-prosody/prosody.cfg.lua-jvb.example
@@ -58,28 +58,21 @@ VirtualHost "jitmeet.example.com"
key = "/etc/prosody/certs/jitmeet.example.com.key";
certificate = "/etc/prosody/certs/jitmeet.example.com.crt";
}
- av_moderation_component = "avmoderation.jitmeet.example.com"
- speakerstats_component = "speakerstats.jitmeet.example.com"
- end_conference_component = "endconference.jitmeet.example.com"
-- we need bosh
modules_enabled = {
"bosh";
"websocket";
"smacks";
"ping"; -- Enable mod_ping
- "speakerstats";
"external_services";
+ "features_identity";
"conference_duration";
- "end_conference";
"muc_lobby_rooms";
"muc_breakout_rooms";
- "av_moderation";
- "room_metadata";
}
c2s_require_encryption = false
lobby_muc = "lobby.jitmeet.example.com"
breakout_rooms_muc = "breakout.jitmeet.example.com"
- room_metadata_component = "metadata.jitmeet.example.com"
main_muc = "conference.jitmeet.example.com"
-- muc_lobby_whitelist = { "recorder.jitmeet.example.com" } -- Here we can whitelist jibri to enter lobby enabled rooms
diff --git a/resources/prosody-plugins/mod_av_moderation.lua b/resources/prosody-plugins/mod_av_moderation.lua
index 4dce74eb2c..817fdb7b00 100644
--- a/resources/prosody-plugins/mod_av_moderation.lua
+++ b/resources/prosody-plugins/mod_av_moderation.lua
@@ -1,6 +1,6 @@
-local avmoderation_component = module:get_option_string('av_moderation_component', 'avmoderation.'..module.host);
+-- TODO: Remove this file after several stable releases when people update their configs
+module:log('warn', 'mod_av_moderation is deprecated and will be removed in a future release. '
+ .. 'Please update your config by removing this module from the list of loaded modules.');
--- Advertise AV Moderation so client can pick up the address and use it
-module:add_identity('component', 'av_moderation', avmoderation_component);
-
-module:depends("jitsi_session");
+module:depends('jitsi_session');
+module:depends('features_identity');
diff --git a/resources/prosody-plugins/mod_av_moderation_component.lua b/resources/prosody-plugins/mod_av_moderation_component.lua
index fa65670792..6ac9560b0b 100644
--- a/resources/prosody-plugins/mod_av_moderation_component.lua
+++ b/resources/prosody-plugins/mod_av_moderation_component.lua
@@ -15,6 +15,12 @@ if muc_component_host == nil then
return;
end
+local main_virtual_host = module:get_option_string('muc_mapper_domain_base');
+if not main_virtual_host then
+ module:log('warn', 'No "muc_mapper_domain_base" option set, disabling AV moderation.');
+ return ;
+end
+
module:log('info', 'Starting av_moderation for %s', muc_component_host);
-- Returns the index of the given element in the table
@@ -357,3 +363,9 @@ process_host_module(muc_component_host, function(host_module, 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);
+
+process_host_module(main_virtual_host, function(host_module)
+ module:context(host_module.host):fire_event('jitsi-add-identity', {
+ name = 'av_moderation'; host = module.host;
+ });
+end);
diff --git a/resources/prosody-plugins/mod_end_conference.lua b/resources/prosody-plugins/mod_end_conference.lua
index 5ebda32178..94b7426959 100644
--- a/resources/prosody-plugins/mod_end_conference.lua
+++ b/resources/prosody-plugins/mod_end_conference.lua
@@ -1,24 +1,21 @@
--- This module is added under the main virtual host domain
---
--- VirtualHost "jitmeet.example.com"
--- modules_enabled = {
--- "end_conference"
--- }
--- end_conference_component = "endconference.jitmeet.example.com"
--
-- Component "endconference.jitmeet.example.com" "end_conference"
-- muc_component = muc.jitmeet.example.com
--
-local get_room_by_name_and_subdomain = module:require 'util'.get_room_by_name_and_subdomain;
+local util = module:require 'util';
+local get_room_by_name_and_subdomain = util.get_room_by_name_and_subdomain;
+local process_host_module = util.process_host_module;
local END_CONFERENCE_REASON = 'The meeting has been terminated';
-- Since this file serves as both the host module and the component, we rely on the assumption that
-- end_conference_component var would only be define for the host and not in the end_conference component
+-- TODO: Remove this if block after several stable releases when people update their configs
local end_conference_component = module:get_option_string('end_conference_component');
if end_conference_component then
- -- Advertise end conference so client can pick up the address and use it
- module:add_identity('component', 'end_conference', end_conference_component);
+ module:log('warn', 'Please update your config by removing muc_end_conference module from '
+ .. 'the list of loaded modules in the main virtual host.');
+ module:depends("features_identity");
return; -- nothing left to do if called as host module
end
@@ -32,6 +29,12 @@ if muc_component_host == nil then
return;
end
+local main_virtual_host = module:get_option_string('muc_mapper_domain_base');
+if not main_virtual_host then
+ module:log('warn', 'No "muc_mapper_domain_base" option set, disabling AV moderation.');
+ return ;
+end
+
module:log('info', 'Starting end_conference for %s', muc_component_host);
-- receives messages from clients to the component to end a conference
@@ -84,3 +87,9 @@ end
-- we will receive messages from the clients
module:hook('message/host', on_message);
+
+process_host_module(main_virtual_host, function(host_module)
+ module:context(host_module.host):fire_event('jitsi-add-identity', {
+ name = 'end_conference'; host = module.host;
+ });
+end);
diff --git a/resources/prosody-plugins/mod_features_identity.lua b/resources/prosody-plugins/mod_features_identity.lua
new file mode 100644
index 0000000000..9a82d1afb8
--- /dev/null
+++ b/resources/prosody-plugins/mod_features_identity.lua
@@ -0,0 +1,8 @@
+-- Other components can use the event 'jitsi-add-identity' to attach identity which
+-- will be advertised by the main virtual host and discovered by clients.
+-- With this we avoid having an almost empty module to just add identity with an extra config
+
+module:hook('jitsi-add-identity', function(event)
+ module:log('info', 'Adding identity %s for host %s', event.name, event.host);
+ module:add_identity('component', event.name, event.host);
+end);
diff --git a/resources/prosody-plugins/mod_room_metadata.lua b/resources/prosody-plugins/mod_room_metadata.lua
index a31abc52cb..a024965d76 100644
--- a/resources/prosody-plugins/mod_room_metadata.lua
+++ b/resources/prosody-plugins/mod_room_metadata.lua
@@ -1,10 +1,6 @@
--- Generic room metadata
--- See mod_room_metadata_component.lua
-
-local COMPONENT_IDENTITY_TYPE = 'room_metadata';
-local room_metadata_component_host = module:get_option_string('room_metadata_component', 'metadata.'..module.host);
+-- TODO: Remove this file after several stable releases when people update their configs
+module:log('warn', 'mod_room_metadata is deprecated and will be removed in a future release. '
+ .. 'Please update your config by removing this module from the list of loaded modules.');
module:depends("jitsi_session");
-
--- Advertise the component so clients can pick up the address and use it
-module:add_identity('component', COMPONENT_IDENTITY_TYPE, room_metadata_component_host);
+module:depends("features_identity");
diff --git a/resources/prosody-plugins/mod_room_metadata_component.lua b/resources/prosody-plugins/mod_room_metadata_component.lua
index a026bc8c07..30edd596c2 100644
--- a/resources/prosody-plugins/mod_room_metadata_component.lua
+++ b/resources/prosody-plugins/mod_room_metadata_component.lua
@@ -1,12 +1,5 @@
-- This module implements a generic metadata storage system for rooms.
--
--- VirtualHost "jitmeet.example.com"
--- modules_enabled = {
--- "room_metadata"
--- }
--- room_metadata_component = "metadata.jitmeet.example.com"
--- main_muc = "conference.jitmeet.example.com"
---
-- Component "metadata.jitmeet.example.com" "room_metadata_component"
-- muc_component = "conference.jitmeet.example.com"
-- breakout_rooms_component = "breakout.jitmeet.example.com"
@@ -37,9 +30,9 @@ if muc_component_host == nil then
return;
end
-local muc_domain_base = module:get_option_string('muc_mapper_domain_base');
-if not muc_domain_base then
- module:log('warn', 'No muc_domain_base option set.');
+local main_virtual_host = module:get_option_string('muc_mapper_domain_base');
+if not main_virtual_host then
+ module:log('warn', 'No muc_mapper_domain_base option set.');
return;
end
@@ -182,7 +175,7 @@ function on_message(event)
if occupant.role ~= 'moderator' then
-- will return a non nil filtered data to use, if it is nil, it is not allowed
- local res = module:context(muc_domain_base):fire_event('jitsi-metadata-allow-moderation',
+ local res = module:context(main_virtual_host):fire_event('jitsi-metadata-allow-moderation',
{ room = room; actor = occupant; key = jsonData.key ; data = jsonData.data; session = session; });
if not res then
@@ -342,3 +335,9 @@ end
-- enable filtering presences
filters.add_filter_hook(filter_session);
+
+process_host_module(main_virtual_host, function(host_module)
+ module:context(host_module.host):fire_event('jitsi-add-identity', {
+ name = 'room_metadata'; host = module.host;
+ });
+end);
diff --git a/resources/prosody-plugins/mod_speakerstats.lua b/resources/prosody-plugins/mod_speakerstats.lua
index bac15c498e..380fde4aed 100644
--- a/resources/prosody-plugins/mod_speakerstats.lua
+++ b/resources/prosody-plugins/mod_speakerstats.lua
@@ -1,6 +1,6 @@
-local speakerstats_component
- = module:get_option_string("speakerstats_component", "speakerstats."..module.host);
+-- TODO: Remove this file after several stable releases when people update their configs
+module:log('warn', 'mod_speakerstats is deprecated and will be removed in a future release. '
+ .. 'Please update your config by removing this module from the list of loaded modules.');
--- Advertise speaker stats so client can pick up the address and start sending
--- dominant speaker events
-module:add_identity("component", "speakerstats", speakerstats_component);
+module:depends('jitsi_session');
+module:depends('features_identity');
diff --git a/resources/prosody-plugins/mod_speakerstats_component.lua b/resources/prosody-plugins/mod_speakerstats_component.lua
index 2e5e1c110a..521cc47f2d 100644
--- a/resources/prosody-plugins/mod_speakerstats_component.lua
+++ b/resources/prosody-plugins/mod_speakerstats_component.lua
@@ -20,13 +20,13 @@ if not have_async then
end
local muc_component_host = module:get_option_string("muc_component");
-local muc_domain_base = module:get_option_string("muc_mapper_domain_base");
+local main_virtual_host = module:get_option_string("muc_mapper_domain_base");
-if muc_component_host == nil or muc_domain_base == nil then
+if muc_component_host == nil or main_virtual_host == nil then
module:log("error", "No muc_component specified. No muc to operate on!");
return;
end
-local breakout_room_component_host = "breakout." .. muc_domain_base;
+local breakout_room_component_host = "breakout." .. main_virtual_host;
module:log("info", "Starting speakerstats for %s", muc_component_host);
@@ -376,3 +376,9 @@ process_host_module(breakout_room_component_host, function(host_module, host)
end);
end
end);
+
+process_host_module(main_virtual_host, function(host_module)
+ module:context(host_module.host):fire_event('jitsi-add-identity', {
+ name = 'speakerstats'; host = module.host;
+ });
+end);
diff --git a/resources/prosody-plugins/util.lib.lua b/resources/prosody-plugins/util.lib.lua
index 452855ef24..f45bbcea73 100644
--- a/resources/prosody-plugins/util.lib.lua
+++ b/resources/prosody-plugins/util.lib.lua
@@ -582,7 +582,7 @@ function process_host_module(name, callback)
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);
+ prosody.events.add_handler('host-activated', process_host, -100); -- make sure everything is loaded
else
process_host(name);
end