From 7c8394f0fd7b3c02954133d6b84c6fe9e03c61b6 Mon Sep 17 00:00:00 2001 From: qvalentin Date: Sun, 5 Feb 2023 17:10:16 +0100 Subject: [PATCH] Use set in lua --- prodsody/docker-compose.yml | 2 ++ prodsody/fix-permissions.sh | 1 + .../prosody-plugins-custom/mod_jitsi_rooms.lua | 16 ++++++++++------ prodsody/mod_jitsi_rooms.lua | 16 ++++++++++------ 4 files changed, 23 insertions(+), 12 deletions(-) create mode 100644 prodsody/fix-permissions.sh diff --git a/prodsody/docker-compose.yml b/prodsody/docker-compose.yml index 5535060..e9b2d49 100644 --- a/prodsody/docker-compose.yml +++ b/prodsody/docker-compose.yml @@ -165,6 +165,8 @@ services: # custom ports: - 5280:5280 + extra_hosts: + - "host.docker.internal:host-gateway" volumes: - ${CONFIG}/prosody/config:/config:Z - ${CONFIG}/prosody/prosody-plugins-custom:/prosody-plugins-custom:Z diff --git a/prodsody/fix-permissions.sh b/prodsody/fix-permissions.sh new file mode 100644 index 0000000..a7e51ab --- /dev/null +++ b/prodsody/fix-permissions.sh @@ -0,0 +1 @@ +sudo chmod 666 jitsi-meet-cfg/prosody/prosody-plugins-custom/mod_jitsi_rooms.lua 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 f517a63..dde9499 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 @@ -30,7 +30,7 @@ function get_participants_for_room(room_name) occupants_json:push({ jid = tostring(occupant.nick), email = tostring(email), - display_name = tostring(nick), + displayName = tostring(nick), avatarURL = tostring(avatarURL) }); end @@ -55,12 +55,16 @@ function get_all_rooms_with_participants() local roomNames = {} for _, v in pairs(actual_rooms) do - table.insert(roomNames, v["jitsi_web_query_room"]) + local roomName = v["jitsi_web_query_room"] + if (roomName ~= nil) then + roomNames[roomName] = true; + end end - local rooms_with_participants = {} - for _, room_name in pairs(roomNames) do - rooms_with_participants[room_name] = get_participants_for_room(room_name) + local rooms_with_participants = array(); + for room_name, _ in pairs(roomNames) do + local room = { roomName = room_name, participants = get_participants_for_room(room_name) } + rooms_with_participants:push(room) end return json.encode(rooms_with_participants) end @@ -143,7 +147,7 @@ function handle_room_event(event) return; end - async_http_request("https://www.toptal.com/developers/postbin/1673793686086-1283829133026", + async_http_request("http://192.168.2.116:8081/roomdata", { method = "POST", body = get_all_rooms_with_participants() diff --git a/prodsody/mod_jitsi_rooms.lua b/prodsody/mod_jitsi_rooms.lua index f517a63..dde9499 100644 --- a/prodsody/mod_jitsi_rooms.lua +++ b/prodsody/mod_jitsi_rooms.lua @@ -30,7 +30,7 @@ function get_participants_for_room(room_name) occupants_json:push({ jid = tostring(occupant.nick), email = tostring(email), - display_name = tostring(nick), + displayName = tostring(nick), avatarURL = tostring(avatarURL) }); end @@ -55,12 +55,16 @@ function get_all_rooms_with_participants() local roomNames = {} for _, v in pairs(actual_rooms) do - table.insert(roomNames, v["jitsi_web_query_room"]) + local roomName = v["jitsi_web_query_room"] + if (roomName ~= nil) then + roomNames[roomName] = true; + end end - local rooms_with_participants = {} - for _, room_name in pairs(roomNames) do - rooms_with_participants[room_name] = get_participants_for_room(room_name) + local rooms_with_participants = array(); + for room_name, _ in pairs(roomNames) do + local room = { roomName = room_name, participants = get_participants_for_room(room_name) } + rooms_with_participants:push(room) end return json.encode(rooms_with_participants) end @@ -143,7 +147,7 @@ function handle_room_event(event) return; end - async_http_request("https://www.toptal.com/developers/postbin/1673793686086-1283829133026", + async_http_request("http://192.168.2.116:8081/roomdata", { method = "POST", body = get_all_rooms_with_participants()