Ok, I solved it on my own but took a different approach.
I inspected the folowing files:
https://github.com/jitsi/jitsi-meet/blob/master/resources/prosody-plugins/util.lib.lua
https://github.com/bjc/prosody/blob/master/plugins/muc/mod_muc.lua
I saw that get_room_from_jid
in jitsi-meets util.lib.lua
was implmented by calling get_room_from_jid
from MUC API (>0.10). So i opened prosodys mod_muc.lua
and found this method. But I found another method, too. It was all_rooms
! And it returns a list of all rooms. Each room object in this list is holding an occupants object and this what the builtin method handle_get_room
is inspecting. (Take a look the orignial muc_size module)
So I tried a little bit and got it:
function get_raw_rooms(ahost)
local component = hosts[ahost];
if component then
local muc = component.modules.muc
if muc and rawget(muc,"all_rooms") then
return muc.all_rooms();
end
end
end
function handle_get_all_rooms(event)
if (not event.request.url.query) then
return { status_code = 400; };
end
local params = parse(event.request.url.query);
local domain_name = params["domain"];
local raw_rooms = get_raw_rooms(domain_name);
local rooms_json = array();
for room in raw_rooms do
local room_jid = room.jid;
local participant_count = 0;
local occupants_json = array();
local occupants = room._occupants;
if occupants then
for _, occupant in room:each_occupant() do
-- filter focus as we keep it as hidden participant
if string.sub(occupant.nick,-string.len("/focus"))~="/focus" then
for _, pr in occupant:each_session() do
participant_count = participant_count + 1;
local nick = pr:get_child_text("nick", "http://jabber.org/protocol/nick") or "";
local email = pr:get_child_text("email") or "";
occupants_json:push({
jid = tostring(occupant.nick),
email = tostring(email),
display_name = tostring(nick)});
end
end
end
end
rooms_json:push({
jid = room_jid,
participant_count = participant_count,
participants = occupants_json
});
end
local result_json={
rooms = rooms_json;
};
-- create json response
return { status_code = 200; body = json.encode(result_json); };
end
Now the new method needs to be routed:
function module.load()
module:depends("http");
module:provides("http", {
default_path = "/";
route = {
["GET room-size"] = function (event) return async_handler_wrapper(event,handle_get_room_size) end;
["GET sessions"] = function () return tostring(it.count(it.keys(prosody.full_sessions))); end;
["GET room"] = function (event) return async_handler_wrapper(event,handle_get_room) end;
["GET all-rooms"] = function (event) return async_handler_wrapper(event,handle_get_all_rooms) end;
};
});
end
I am able to receive the list of all rooms by curl request:
curl 'http://localhost:5280/all-rooms?domain=conference.jitsi-meet.example.com' -i
Be careful! Although my domain is jitsi-meet.example… I need to request conference.jitsi-meet.example… because my get_raw_rooms function is not respecting the muc_mapper_domain_prefix
. This needs to be implemented like jitsi-meets util.lib.lua
did.
I hope this helps anybody and maybe it will find its way into the jitsi source code or maybe we can offer a module by ourself.