From e21ca799d66481d40a4f3d4c11eed793c95a86c3 Mon Sep 17 00:00:00 2001 From: qvalentin Date: Sat, 8 Jul 2023 13:37:32 +0200 Subject: [PATCH] fix url encoding in prosody module --- prodsody/fix-permissions.sh | 0 .../prosody-plugins-custom/mod_jitsi_rooms.lua | 16 +++++++--------- 2 files changed, 7 insertions(+), 9 deletions(-) mode change 100644 => 100755 prodsody/fix-permissions.sh diff --git a/prodsody/fix-permissions.sh b/prodsody/fix-permissions.sh old mode 100644 new mode 100755 diff --git a/prodsody/jitsi-meet-cfg/prosody/prosody-plugins-custom/mod_jitsi_rooms.lua b/prodsody/jitsi-meet-cfg/prosody/prosody-plugins-custom/mod_jitsi_rooms.lua index dde9499..cfe138b 100644 --- a/prodsody/jitsi-meet-cfg/prosody/prosody-plugins-custom/mod_jitsi_rooms.lua +++ b/prodsody/jitsi-meet-cfg/prosody/prosody-plugins-custom/mod_jitsi_rooms.lua @@ -4,6 +4,7 @@ local json = require "util.json"; local array = require "util.array"; local iterators = require "util.iterators"; local jid = require "util.jid"; +local http = require "util.http"; local async_handler_wrapper = module:require "util".async_handler_wrapper; 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) - 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(); if room then local occupants = room._occupants; @@ -47,7 +48,6 @@ function get_participants_for_room(room_name) end function get_all_rooms_with_participants() - local sessions = prosody.full_sessions; local someTable = (it.join(it.keys(sessions))); @@ -74,7 +74,7 @@ end -- @return GET response, containing a json with participants details function handle_get_sessions(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 function module.load() @@ -86,9 +86,9 @@ function module.load() module:log("info", "Hello! You can reach me at: %s", module:http_url()); module:provides("http", { 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 @@ -125,7 +125,6 @@ end --- Checks if event is triggered by healthchecks or focus user. function is_system_event(event) - if event == nil or event.room == nil or event.room.jid == nil then return true; end @@ -147,12 +146,11 @@ function handle_room_event(event) return; end - async_http_request("http://192.168.2.116:8081/roomdata", + async_http_request("http://jitsi-rooms:8081/roomdata", { method = "POST", body = get_all_rooms_with_participants() }) - end --Helper function to wait till a component is loaded before running the given callback