|
|
@@ -28,6 +28,9 @@ local jid_bare = require 'util.jid'.bare;
|
|
28
|
28
|
local filters = require 'util.filters';
|
|
29
|
29
|
local st = require 'util.stanza';
|
|
30
|
30
|
local MUC_NS = 'http://jabber.org/protocol/muc';
|
|
|
31
|
+local DISCO_INFO_NS = 'http://jabber.org/protocol/disco#info';
|
|
|
32
|
+local DISPLAY_NAME_REQUIRED_FEATURE = 'http://jitsi.org/protocol/lobbyrooms#displayname_required';
|
|
|
33
|
+local LOBBY_IDENTITY_TYPE = 'lobbyrooms';
|
|
31
|
34
|
|
|
32
|
35
|
local is_healthcheck_room = module:require "util".is_healthcheck_room;
|
|
33
|
36
|
|
|
|
@@ -42,7 +45,14 @@ if lobby_muc_component_config == nil then
|
|
42
|
45
|
return ;
|
|
43
|
46
|
end
|
|
44
|
47
|
|
|
45
|
|
-local whitelist = module:get_option_set("muc_lobby_whitelist", {});
|
|
|
48
|
+local whitelist;
|
|
|
49
|
+local check_display_name_required;
|
|
|
50
|
+local function load_config()
|
|
|
51
|
+ whitelist = module:get_option_set("muc_lobby_whitelist", {});
|
|
|
52
|
+ check_display_name_required
|
|
|
53
|
+ = module:get_option_boolean("muc_lobby_check_display_name_required", true);
|
|
|
54
|
+end
|
|
|
55
|
+load_config();
|
|
46
|
56
|
|
|
47
|
57
|
local lobby_muc_service;
|
|
48
|
58
|
local main_muc_service;
|
|
|
@@ -84,6 +94,9 @@ function filter_stanza(stanza)
|
|
84
|
94
|
end
|
|
85
|
95
|
|
|
86
|
96
|
return nil;
|
|
|
97
|
+ elseif stanza.name == 'iq' and stanza:get_child('query', DISCO_INFO_NS) then
|
|
|
98
|
+ -- allow disco info from the lobby component
|
|
|
99
|
+ return stanza;
|
|
87
|
100
|
end
|
|
88
|
101
|
|
|
89
|
102
|
return nil;
|
|
|
@@ -125,7 +138,24 @@ function process_lobby_muc_loaded(lobby_muc, host_module)
|
|
125
|
138
|
filters.add_filter_hook(filter_session);
|
|
126
|
139
|
|
|
127
|
140
|
-- Advertise lobbyrooms support on main domain so client can pick up the address and use it
|
|
128
|
|
- module:add_identity('component', 'lobbyrooms', lobby_muc_component_config);
|
|
|
141
|
+ module:add_identity('component', LOBBY_IDENTITY_TYPE, lobby_muc_component_config);
|
|
|
142
|
+
|
|
|
143
|
+ -- Tag the disco#info response with a feature that display name is required
|
|
|
144
|
+ -- when the conference name from the web request has a lobby enabled.
|
|
|
145
|
+ host_module:hook("host-disco-info-node", function (event)
|
|
|
146
|
+ local session, reply, node = event.origin, event.reply, event.node;
|
|
|
147
|
+ if node == LOBBY_IDENTITY_TYPE
|
|
|
148
|
+ and session.jitsi_web_query_room
|
|
|
149
|
+ and main_muc_service
|
|
|
150
|
+ and check_display_name_required then
|
|
|
151
|
+ local room = main_muc_service.get_room_from_jid(
|
|
|
152
|
+ jid_bare(session.jitsi_web_query_room .. '@' .. main_muc_component_config));
|
|
|
153
|
+ if room and room._data.lobbyroom then
|
|
|
154
|
+ reply:tag("feature", { var = DISPLAY_NAME_REQUIRED_FEATURE }):up();
|
|
|
155
|
+ end
|
|
|
156
|
+ end
|
|
|
157
|
+ event.exists = true;
|
|
|
158
|
+ end);
|
|
129
|
159
|
|
|
130
|
160
|
local room_mt = lobby_muc_service.room_mt;
|
|
131
|
161
|
-- we base affiliations (roles) in lobby muc component to be based on the roles in the main muc
|
|
|
@@ -256,3 +286,25 @@ process_host_module(main_muc_component_config, function(host_module, host)
|
|
256
|
286
|
end
|
|
257
|
287
|
end, -4); -- the default hook on members_only module is on -5
|
|
258
|
288
|
end);
|
|
|
289
|
+
|
|
|
290
|
+-- Extract 'room' param from URL when session is created
|
|
|
291
|
+function update_session(event)
|
|
|
292
|
+ local session = event.session;
|
|
|
293
|
+
|
|
|
294
|
+ if session.jitsi_web_query_room then
|
|
|
295
|
+ -- no need for an update
|
|
|
296
|
+ return;
|
|
|
297
|
+ end
|
|
|
298
|
+
|
|
|
299
|
+ local query = event.request.url.query;
|
|
|
300
|
+ if query ~= nil then
|
|
|
301
|
+ local params = formdecode(query);
|
|
|
302
|
+ -- The room name and optional prefix from the web query
|
|
|
303
|
+ session.jitsi_web_query_room = params.room;
|
|
|
304
|
+ session.jitsi_web_query_prefix = params.prefix or "";
|
|
|
305
|
+ end
|
|
|
306
|
+end
|
|
|
307
|
+
|
|
|
308
|
+module:hook_global("bosh-session", update_session);
|
|
|
309
|
+module:hook_global("websocket-session", update_session);
|
|
|
310
|
+module:hook_global('config-reloaded', load_config);
|