From d5639134992b77bd549dbe5ee2925a8be99140a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BC=D1=8F=D0=BD=20=D0=9C=D0=B8=D0=BD=D0=BA?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Tue, 28 Jan 2025 09:54:47 -0600 Subject: [PATCH] feat: Reads region from http headers and set it in presence. (#15531) * feat: Reads region from http headers and set it in presence. * chore(deps) lib-jitsi-meet@latest https://github.com/jitsi/lib-jitsi-meet/compare/v1906.0.0+dfc23df4...v1907.0.0+0d3304b7 --- package-lock.json | 10 +++--- package.json | 2 +- .../prosody-plugins/mod_jitsi_session.lua | 3 ++ .../prosody-plugins/mod_muc_meeting_id.lua | 34 ++++++++++++++----- 4 files changed, 35 insertions(+), 14 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8f84a31c7a..ba50b6ec8f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -62,7 +62,7 @@ "js-md5": "0.6.1", "js-sha512": "0.8.0", "jwt-decode": "2.2.0", - "lib-jitsi-meet": "https://github.com/jitsi/lib-jitsi-meet/releases/download/v1906.0.0+dfc23df4/lib-jitsi-meet.tgz", + "lib-jitsi-meet": "https://github.com/jitsi/lib-jitsi-meet/releases/download/v1907.0.0+0d3304b7/lib-jitsi-meet.tgz", "lodash-es": "4.17.21", "moment": "2.29.4", "moment-duration-format": "2.2.2", @@ -16954,8 +16954,8 @@ }, "node_modules/lib-jitsi-meet": { "version": "0.0.0", - "resolved": "https://github.com/jitsi/lib-jitsi-meet/releases/download/v1906.0.0+dfc23df4/lib-jitsi-meet.tgz", - "integrity": "sha512-4w+/VkFNzj6rnbogfF6JHgL48pxo/Pq4GX6RXodnUGJMwu1Zc+nGw3SR/KJYqtxCfO9hAb+NBZVQfQvN16xRxg==", + "resolved": "https://github.com/jitsi/lib-jitsi-meet/releases/download/v1907.0.0+0d3304b7/lib-jitsi-meet.tgz", + "integrity": "sha512-qll80OJZol+xlDt3n58SqGPYQPer72C28XE9lSEtfOx6XdFdhLYXSzaNpPY4OP2tFjJqNX+Y2ZQkSkARGSqVrg==", "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { @@ -37739,8 +37739,8 @@ } }, "lib-jitsi-meet": { - "version": "https://github.com/jitsi/lib-jitsi-meet/releases/download/v1906.0.0+dfc23df4/lib-jitsi-meet.tgz", - "integrity": "sha512-4w+/VkFNzj6rnbogfF6JHgL48pxo/Pq4GX6RXodnUGJMwu1Zc+nGw3SR/KJYqtxCfO9hAb+NBZVQfQvN16xRxg==", + "version": "https://github.com/jitsi/lib-jitsi-meet/releases/download/v1907.0.0+0d3304b7/lib-jitsi-meet.tgz", + "integrity": "sha512-qll80OJZol+xlDt3n58SqGPYQPer72C28XE9lSEtfOx6XdFdhLYXSzaNpPY4OP2tFjJqNX+Y2ZQkSkARGSqVrg==", "requires": { "@jitsi/js-utils": "2.2.1", "@jitsi/logger": "2.0.2", diff --git a/package.json b/package.json index 55acb1a4bd..67b508c325 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "js-md5": "0.6.1", "js-sha512": "0.8.0", "jwt-decode": "2.2.0", - "lib-jitsi-meet": "https://github.com/jitsi/lib-jitsi-meet/releases/download/v1906.0.0+dfc23df4/lib-jitsi-meet.tgz", + "lib-jitsi-meet": "https://github.com/jitsi/lib-jitsi-meet/releases/download/v1907.0.0+0d3304b7/lib-jitsi-meet.tgz", "lodash-es": "4.17.21", "moment": "2.29.4", "moment-duration-format": "2.2.2", diff --git a/resources/prosody-plugins/mod_jitsi_session.lua b/resources/prosody-plugins/mod_jitsi_session.lua index 8d281c4343..4ea2986ed6 100644 --- a/resources/prosody-plugins/mod_jitsi_session.lua +++ b/resources/prosody-plugins/mod_jitsi_session.lua @@ -3,6 +3,7 @@ module:set_global(); local formdecode = require "util.http".formdecode; +local region_header_name = module:get_option_string('region_header_name', 'x_proxy_region'); -- Extract the following parameters from the URL and set them in the session: -- * previd: for session resumption @@ -24,6 +25,8 @@ function init_session(event) session.jitsi_web_query_room = params.room; session.jitsi_web_query_prefix = params.prefix or ""; end + + session.user_region = request.headers[region_header_name]; end module:hook_global("bosh-session", init_session, 1); diff --git a/resources/prosody-plugins/mod_muc_meeting_id.lua b/resources/prosody-plugins/mod_muc_meeting_id.lua index 00eecac346..be38a8b0b2 100644 --- a/resources/prosody-plugins/mod_muc_meeting_id.lua +++ b/resources/prosody-plugins/mod_muc_meeting_id.lua @@ -75,17 +75,35 @@ module:hook('muc-broadcast-presence', function (event) end end); ---- Avoids any participant joining the room in the interval between creating the room ---- and jicofo entering the room -module:hook('muc-occupant-pre-join', function (event) - local room, stanza = event.room, event.stanza; - - -- we skip processing only if jicofo_lock is set to false - if room._data.jicofo_lock == false or is_healthcheck_room(room.jid) then +local function process_region(session, stanza) + if not session.user_region then + return; + end + + local region = stanza:get_child_text('jitsi_participant_region'); + if region then + return; + end + + stanza:tag('jitsi_participant_region'):text(session.user_region):up(); +end + +--- Avoids any participant joining the room in the interval between creating the room +--- and jicofo entering the room +module:hook('muc-occupant-pre-join', function (event) + local occupant, room, stanza = event.occupant, event.room, event.stanza; + + local is_health_room = is_healthcheck_room(room.jid); + -- check for region + if not is_admin(occupant.bare_jid) and not is_health_room then + process_region(event.origin, stanza); + end + + -- we skip processing only if jicofo_lock is set to false + if room._data.jicofo_lock == false or is_health_room then return; end - local occupant = event.occupant; if ends_with(occupant.nick, '/focus') then module:fire_event('jicofo-unlock-room', { room = room; }); else