fix url encoding in prosody module
continuous-integration/drone/push Build is passing Details

This commit is contained in:
qvalentin 2023-07-08 13:37:32 +02:00
parent 77a00e68e9
commit e21ca799d6
2 changed files with 7 additions and 9 deletions

0
prodsody/fix-permissions.sh Normal file → Executable file
View File

View File

@ -4,6 +4,7 @@ local json = require "util.json";
local array = require "util.array"; local array = require "util.array";
local iterators = require "util.iterators"; local iterators = require "util.iterators";
local jid = require "util.jid"; local jid = require "util.jid";
local http = require "util.http";
local async_handler_wrapper = module:require "util".async_handler_wrapper; local async_handler_wrapper = module:require "util".async_handler_wrapper;
local get_room_from_jid = module:require "util".get_room_from_jid; local get_room_from_jid = module:require "util".get_room_from_jid;
@ -12,9 +13,9 @@ local domain_name = "meet.jitsi"
function get_participants_for_room(room_name) function get_participants_for_room(room_name)
local room_address = jid.join(room_name, muc_domain_prefix .. "." .. domain_name); local room_address = jid.join(room_name, muc_domain_prefix .. "." .. domain_name);
local room = get_room_from_jid(room_address); local decoded_room_address = http.urldecode(room_address);
local room = get_room_from_jid(decoded_room_address);
local occupants_json = array(); local occupants_json = array();
if room then if room then
local occupants = room._occupants; local occupants = room._occupants;
@ -47,7 +48,6 @@ function get_participants_for_room(room_name)
end end
function get_all_rooms_with_participants() function get_all_rooms_with_participants()
local sessions = prosody.full_sessions; local sessions = prosody.full_sessions;
local someTable = (it.join(it.keys(sessions))); local someTable = (it.join(it.keys(sessions)));
@ -74,7 +74,7 @@ end
-- @return GET response, containing a json with participants details -- @return GET response, containing a json with participants details
function handle_get_sessions(event) function handle_get_sessions(event)
handle_room_event() handle_room_event()
return { status_code = 200; body = get_all_rooms_with_participants() }; return { status_code = 200, body = get_all_rooms_with_participants() };
end end
function module.load() function module.load()
@ -86,9 +86,9 @@ function module.load()
module:log("info", "Hello! You can reach me at: %s", module:http_url()); module:log("info", "Hello! You can reach me at: %s", module:http_url());
module:provides("http", { module:provides("http", {
route = { route = {
["GET"] = function(event) return async_handler_wrapper(event, handle_get_sessions) end; ["GET"] = function(event) return async_handler_wrapper(event, handle_get_sessions) end,
}; },
}); });
end end
@ -125,7 +125,6 @@ end
--- Checks if event is triggered by healthchecks or focus user. --- Checks if event is triggered by healthchecks or focus user.
function is_system_event(event) function is_system_event(event)
if event == nil or event.room == nil or event.room.jid == nil then if event == nil or event.room == nil or event.room.jid == nil then
return true; return true;
end end
@ -147,12 +146,11 @@ function handle_room_event(event)
return; return;
end end
async_http_request("http://192.168.2.116:8081/roomdata", async_http_request("http://jitsi-rooms:8081/roomdata",
{ {
method = "POST", method = "POST",
body = get_all_rooms_with_participants() body = get_all_rooms_with_participants()
}) })
end end
--Helper function to wait till a component is loaded before running the given callback --Helper function to wait till a component is loaded before running the given callback