Compare commits

...

5 Commits

Author SHA1 Message Date
Дамян Минков
67d6818f50 squash: Fixes unavailable presence to jicofo for visitors.
On the cost of one string check for contains a substring.
2022-05-10 14:18:49 -05:00
Дамян Минков
86dc101d33 squash: Drop two jid splits and two string check in favour of one string.find. 2022-05-10 11:19:43 -05:00
Дамян Минков
28e12a636e squash: Find focus occupant once.
If focus leaves the conference is over anyway.
2022-05-10 10:34:00 -05:00
Дамян Минков
0c75131a6c feat: Routes visitor's presences to jicofo. 2022-04-27 10:14:44 -05:00
Дамян Минков
3d97a36c61 debug: Experimenting with visitors. 2022-04-27 10:14:10 -05:00
7 changed files with 123 additions and 0 deletions

View File

@@ -263,6 +263,10 @@ function occupant_joined(event)
return;
end
if event.occupant.role == 'visitor' then
return;
end
if room.av_moderation then
for _,mediaType in pairs({'audio', 'video'}) do
if room.av_moderation[mediaType] then

View File

@@ -23,6 +23,10 @@ function occupant_joined(event)
local room = event.room;
local occupant = event.occupant;
if event.occupant.role == 'visitor' then
return;
end
local participant_count = it.count(room:each_occupant());
if participant_count > 1 then

View File

@@ -333,6 +333,10 @@ end
function on_occupant_joined(event)
local room = event.room;
if event.occupant.role == 'visitor' then
return;
end
if is_healthcheck_room(room.jid) then
return;
end

View File

@@ -8,6 +8,10 @@ local MUC_NS = "http://jabber.org/protocol/muc";
module:hook("muc-occupant-pre-join", function (event)
local room, stanza = event.room, event.stanza;
if event.occupant.role == 'visitor' then
return;
end
local user, domain, res = jid_split(event.stanza.attr.from);
--no user object means no way to check whitelist

View File

@@ -0,0 +1,99 @@
local jid_node = require 'util.jid'.node;
local jid_resource = require "util.jid".resource;
local st = require "util.stanza";
-- Add the following config to the main muc component
-- muc_room_default_presence_broadcast = {
-- visitor = false;
-- participant = true;
-- moderator = true;
-- };
-- This will filter presence of visitors to be broadcast to any visitor or participant including jicofo
-- We handle the jicofo part specially and forward the presence
--
-- To activate the module create a separate virtualhost, like
-- VirtualHost "visitors.jitmeet.example.com"
-- authentication = "anonymous"
-- modules_enabled = {
-- "bosh";
-- "ping"; -- Enable mod_ping
-- "external_services";
-- "conference_duration";
-- "muc_visitors";
-- }
-- c2s_require_encryption = false
-- main_muc = "conference.jitmeet.example.com"
local main_muc_component_config = module:get_option_string('main_muc');
function starts_with(str, start)
return str:sub(1, #start) == start
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(
main_muc_component_config,
function(host_module, host)
main_muc_service = prosody.hosts[host].modules.muc;
host_module:hook('muc-occupant-pre-join', function (event)
local occupant = event.occupant;
if string.find(occupant.bare_jid, module.host) then
occupant.role = 'visitor';
--occupant.is_visitor = true;
end
end, 3);
host_module:hook('muc-broadcast-presence', function (event)
local occupant = event.occupant;
-- we are interested only of visitors presence to send it to jicofo
--if not occupant.is_visitor then
if not string.find(occupant.bare_jid, module.host) then
return;
end
local room = event.room;
if not room._data.focus_occupant then
for _, n_occupant in room:each_occupant() do
if jid_node(n_occupant.jid) == 'focus' then
room._data.focus_occupant = n_occupant;
room:save(true);
break;
end
end
end
local actor, base_presence, nick, reason, x
= event.actor, event.stanza, event.nick, event.reason, event.x;
local actor_nick;
if actor then
actor_nick = jid_resource(room:get_occupant_jid(actor));
end
local full_x = st.clone(x.full or x);
room:build_item_list(occupant, full_x, false, nick, actor_nick, actor, reason);
local full_p = st.clone(base_presence):add_child(full_x);
room:route_to_occupant(room._data.focus_occupant, full_p);
return;
end);
end
);

View File

@@ -133,6 +133,10 @@ module:hook("muc-occupant-joined", function(event)
return
end
if event.occupant.role == 'visitor' then
return;
end
local data = {
type = "old-polls",
polls = {},

View File

@@ -172,6 +172,10 @@ function occupant_joined(event)
return;
end
if event.occupant.role == 'visitor' then
return;
end
local occupant = event.occupant;
local nick = jid_resource(occupant.nick);