Skip to content

Commit

Permalink
feat(visitors): Allow occupants switching from breakout to main room.
Browse files Browse the repository at this point in the history
  • Loading branch information
damencho committed Sep 20, 2024
1 parent 8f1c635 commit 09d5797
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
11 changes: 11 additions & 0 deletions resources/prosody-plugins/mod_muc_breakout_rooms.lua
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,16 @@ function exist_occupants_in_rooms(main_room)
return false;
end

function on_occupant_pre_leave(event)
local room, occupant, session, stanza = event.room, event.occupant, event.origin, event.stanza;

local main_room = get_main_room(room.jid);

prosody.events.fire_event('jitsi-breakout-occupant-leaving', {
room = room; main_room = main_room; occupant = occupant; stanza = stanza; session = session;
});
end

function on_occupant_left(event)
local room_jid = event.room.jid;

Expand Down Expand Up @@ -510,6 +520,7 @@ function process_breakout_rooms_muc_loaded(breakout_rooms_muc, host_module)
host_module:hook('muc-occupant-joined', on_occupant_joined);
host_module:hook('muc-occupant-left', on_occupant_left);
host_module:hook('muc-room-pre-create', on_breakout_room_pre_create);
host_module:hook('muc-occupant-pre-leave', on_occupant_pre_leave);

host_module:hook('muc-disco#info', function (event)
local room = event.room;
Expand Down
19 changes: 19 additions & 0 deletions resources/prosody-plugins/mod_visitors_component.lua
Original file line number Diff line number Diff line change
Expand Up @@ -636,3 +636,22 @@ prosody.events.add_handler('pre-jitsi-authentication', function(session)
return session.customusername;
end
end);

-- when occupant is leaving breakout to join the main room and visitors are enabled
-- make sure we will allow that participant to join as it is already part of the main room
function handle_occupant_leaving_breakout(event)
local main_room, occupant, stanza = event.main_room, event.occupant, event.stanza;
local presence_status = stanza:get_child_text('status');

if presence_status ~= 'switch_room' or not visitors_promotion_map[main_room.jid] then
return;
end

local node = jid.node(occupant.bare_jid);

visitors_promotion_map[main_room.jid][node] = {
from = 'none';
jid = occupant.bare_jid;
};
end
module:hook_global('jitsi-breakout-occupant-leaving', handle_occupant_leaving_breakout);

0 comments on commit 09d5797

Please sign in to comment.