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

This commit is contained in:
qvalentin 2023-07-08 12:32:42 +02:00
parent a5d769e9b5
commit 77a00e68e9
3 changed files with 9 additions and 11 deletions

View File

@ -10,7 +10,7 @@
### Get started ### Get started
- run `./run_dev.sh` - run `./run_dev.sh`
- open [https://localhost:8443/](https://localhost:8443/) - open [https://localhost:8443/](https://localhost:8443/) (accept the risk about self-signed certs)
- make changes to mod_jitsi_rooms.lua and save the file - make changes to mod_jitsi_rooms.lua and save the file
- prosody will be restarted - prosody will be restarted
- join a room in jitsi - join a room in jitsi

View File

@ -347,7 +347,7 @@ services:
meet.jitsi: meet.jitsi:
jitsi-rooms: jitsi-rooms:
image: jitsi-rooms:67y5d9y2zbi7wkqm2jpcjj1k2614qwx2 image: jitsi-rooms
restart: ${RESTART_POLICY:-unless-stopped} restart: ${RESTART_POLICY:-unless-stopped}
ports: ports:
- '9160:9160' - '9160:9160'

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