Browse Source

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
factor2
Дамян Минков 4 months ago
parent
commit
d563913499
No account linked to committer's email address

+ 5
- 5
package-lock.json View File

62
         "js-md5": "0.6.1",
62
         "js-md5": "0.6.1",
63
         "js-sha512": "0.8.0",
63
         "js-sha512": "0.8.0",
64
         "jwt-decode": "2.2.0",
64
         "jwt-decode": "2.2.0",
65
-        "lib-jitsi-meet": "https://github.com/jitsi/lib-jitsi-meet/releases/download/v1906.0.0+dfc23df4/lib-jitsi-meet.tgz",
65
+        "lib-jitsi-meet": "https://github.com/jitsi/lib-jitsi-meet/releases/download/v1907.0.0+0d3304b7/lib-jitsi-meet.tgz",
66
         "lodash-es": "4.17.21",
66
         "lodash-es": "4.17.21",
67
         "moment": "2.29.4",
67
         "moment": "2.29.4",
68
         "moment-duration-format": "2.2.2",
68
         "moment-duration-format": "2.2.2",
16954
     },
16954
     },
16955
     "node_modules/lib-jitsi-meet": {
16955
     "node_modules/lib-jitsi-meet": {
16956
       "version": "0.0.0",
16956
       "version": "0.0.0",
16957
-      "resolved": "https://github.com/jitsi/lib-jitsi-meet/releases/download/v1906.0.0+dfc23df4/lib-jitsi-meet.tgz",
16958
-      "integrity": "sha512-4w+/VkFNzj6rnbogfF6JHgL48pxo/Pq4GX6RXodnUGJMwu1Zc+nGw3SR/KJYqtxCfO9hAb+NBZVQfQvN16xRxg==",
16957
+      "resolved": "https://github.com/jitsi/lib-jitsi-meet/releases/download/v1907.0.0+0d3304b7/lib-jitsi-meet.tgz",
16958
+      "integrity": "sha512-qll80OJZol+xlDt3n58SqGPYQPer72C28XE9lSEtfOx6XdFdhLYXSzaNpPY4OP2tFjJqNX+Y2ZQkSkARGSqVrg==",
16959
       "hasInstallScript": true,
16959
       "hasInstallScript": true,
16960
       "license": "Apache-2.0",
16960
       "license": "Apache-2.0",
16961
       "dependencies": {
16961
       "dependencies": {
37739
       }
37739
       }
37740
     },
37740
     },
37741
     "lib-jitsi-meet": {
37741
     "lib-jitsi-meet": {
37742
-      "version": "https://github.com/jitsi/lib-jitsi-meet/releases/download/v1906.0.0+dfc23df4/lib-jitsi-meet.tgz",
37743
-      "integrity": "sha512-4w+/VkFNzj6rnbogfF6JHgL48pxo/Pq4GX6RXodnUGJMwu1Zc+nGw3SR/KJYqtxCfO9hAb+NBZVQfQvN16xRxg==",
37742
+      "version": "https://github.com/jitsi/lib-jitsi-meet/releases/download/v1907.0.0+0d3304b7/lib-jitsi-meet.tgz",
37743
+      "integrity": "sha512-qll80OJZol+xlDt3n58SqGPYQPer72C28XE9lSEtfOx6XdFdhLYXSzaNpPY4OP2tFjJqNX+Y2ZQkSkARGSqVrg==",
37744
       "requires": {
37744
       "requires": {
37745
         "@jitsi/js-utils": "2.2.1",
37745
         "@jitsi/js-utils": "2.2.1",
37746
         "@jitsi/logger": "2.0.2",
37746
         "@jitsi/logger": "2.0.2",

+ 1
- 1
package.json View File

68
     "js-md5": "0.6.1",
68
     "js-md5": "0.6.1",
69
     "js-sha512": "0.8.0",
69
     "js-sha512": "0.8.0",
70
     "jwt-decode": "2.2.0",
70
     "jwt-decode": "2.2.0",
71
-    "lib-jitsi-meet": "https://github.com/jitsi/lib-jitsi-meet/releases/download/v1906.0.0+dfc23df4/lib-jitsi-meet.tgz",
71
+    "lib-jitsi-meet": "https://github.com/jitsi/lib-jitsi-meet/releases/download/v1907.0.0+0d3304b7/lib-jitsi-meet.tgz",
72
     "lodash-es": "4.17.21",
72
     "lodash-es": "4.17.21",
73
     "moment": "2.29.4",
73
     "moment": "2.29.4",
74
     "moment-duration-format": "2.2.2",
74
     "moment-duration-format": "2.2.2",

+ 3
- 0
resources/prosody-plugins/mod_jitsi_session.lua View File

3
 module:set_global();
3
 module:set_global();
4
 
4
 
5
 local formdecode = require "util.http".formdecode;
5
 local formdecode = require "util.http".formdecode;
6
+local region_header_name = module:get_option_string('region_header_name', 'x_proxy_region');
6
 
7
 
7
 -- Extract the following parameters from the URL and set them in the session:
8
 -- Extract the following parameters from the URL and set them in the session:
8
 -- * previd: for session resumption
9
 -- * previd: for session resumption
24
         session.jitsi_web_query_room = params.room;
25
         session.jitsi_web_query_room = params.room;
25
         session.jitsi_web_query_prefix = params.prefix or "";
26
         session.jitsi_web_query_prefix = params.prefix or "";
26
     end
27
     end
28
+
29
+    session.user_region = request.headers[region_header_name];
27
 end
30
 end
28
 
31
 
29
 module:hook_global("bosh-session", init_session, 1);
32
 module:hook_global("bosh-session", init_session, 1);

+ 21
- 3
resources/prosody-plugins/mod_muc_meeting_id.lua View File

75
     end
75
     end
76
 end);
76
 end);
77
 
77
 
78
+local function process_region(session, stanza)
79
+    if not session.user_region then
80
+        return;
81
+    end
82
+
83
+    local region = stanza:get_child_text('jitsi_participant_region');
84
+    if region then
85
+        return;
86
+    end
87
+
88
+    stanza:tag('jitsi_participant_region'):text(session.user_region):up();
89
+end
90
+
78
 --- Avoids any participant joining the room in the interval between creating the room
91
 --- Avoids any participant joining the room in the interval between creating the room
79
 --- and jicofo entering the room
92
 --- and jicofo entering the room
80
 module:hook('muc-occupant-pre-join', function (event)
93
 module:hook('muc-occupant-pre-join', function (event)
81
-    local room, stanza = event.room, event.stanza;
94
+    local occupant, room, stanza = event.occupant, event.room, event.stanza;
95
+
96
+    local is_health_room = is_healthcheck_room(room.jid);
97
+    -- check for region
98
+    if not is_admin(occupant.bare_jid) and not is_health_room then
99
+        process_region(event.origin, stanza);
100
+    end
82
 
101
 
83
     -- we skip processing only if jicofo_lock is set to false
102
     -- we skip processing only if jicofo_lock is set to false
84
-    if room._data.jicofo_lock == false or is_healthcheck_room(room.jid) then
103
+    if room._data.jicofo_lock == false or is_health_room then
85
         return;
104
         return;
86
     end
105
     end
87
 
106
 
88
-    local occupant = event.occupant;
89
     if ends_with(occupant.nick, '/focus') then
107
     if ends_with(occupant.nick, '/focus') then
90
         module:fire_event('jicofo-unlock-room', { room = room; });
108
         module:fire_event('jicofo-unlock-room', { room = room; });
91
     else
109
     else

Loading…
Cancel
Save