|
@@ -8,7 +8,7 @@
|
8
|
8
|
-- lobby_muc = "lobby.jitmeet.example.com"
|
9
|
9
|
-- main_muc = "conference.jitmeet.example.com"
|
10
|
10
|
--
|
|
11
|
+-- Component "lobby.jitmeet.example.com" "muc"
|
11
|
12
|
-- storage = "memory"
|
12
|
13
|
-- muc_room_cache_size = 1000
|
13
|
14
|
-- restrict_room_creation = true
|
|
@@ -42,6 +42,8 @@ if lobby_muc_component_config == nil then
|
42
|
42
|
return ;
|
43
|
43
|
end
|
44
|
44
|
|
|
45
|
+local whitelist = module:get_option_set("muc_lobby_whitelist", {});
|
|
46
|
+
|
45
|
47
|
local lobby_muc_service;
|
46
|
48
|
local main_muc_service;
|
47
|
49
|
|
|
@@ -165,51 +167,48 @@ end);
|
165
|
167
|
process_host_module(main_muc_component_config, function(host_module, host)
|
166
|
168
|
main_muc_service = prosody.hosts[host].modules.muc;
|
167
|
169
|
|
168
|
|
- -- adds new field to the form so moderators can use it to set shared password
|
169
|
|
- host_module:hook('muc-config-form', function(event)
|
170
|
|
- table.insert(event.form, {
|
171
|
|
- name = 'muc#roomconfig_lobbypassword';
|
172
|
|
- type = 'text-private';
|
173
|
|
- label = 'Shared Password';
|
174
|
|
- value = '';
|
175
|
|
- });
|
176
|
|
- end, 90-4);
|
177
|
|
-
|
178
|
170
|
-- hooks when lobby is enabled to create its room, only done here or by admin
|
179
|
171
|
host_module:hook('muc-config-submitted', function(event)
|
|
172
|
+ local room = event.room;
|
180
|
173
|
local members_only = event.fields['muc#roomconfig_membersonly'] and true or nil;
|
181
|
174
|
if members_only then
|
182
|
|
- local node = jid_split(event.room.jid);
|
|
175
|
+ local node = jid_split(room.jid);
|
183
|
176
|
|
184
|
177
|
local lobby_room_jid = node .. '@' .. lobby_muc_component_config;
|
185
|
178
|
if not lobby_muc_service.get_room_from_jid(lobby_room_jid) then
|
186
|
179
|
local new_room = lobby_muc_service.create_room(lobby_room_jid);
|
187
|
|
- new_room.main_room = event.room;
|
188
|
|
- event.room._data.lobbyroom = lobby_room_jid;
|
|
180
|
+ new_room.main_room = room;
|
|
181
|
+ room._data.lobbyroom = new_room;
|
189
|
182
|
event.status_codes["104"] = true;
|
190
|
|
-
|
191
|
|
- local lobby_password = event.fields['muc#roomconfig_lobbypassword'];
|
192
|
|
- if lobby_password then
|
193
|
|
- new_room.main_room.lobby_password = lobby_password;
|
194
|
|
- end
|
195
|
183
|
end
|
|
184
|
+ elseif room._data.lobbyroom then
|
|
185
|
+ room._data.lobbyroom:destroy(room.jid, 'Lobby room closed.');
|
|
186
|
+ room._data.lobbyroom = nil;
|
|
187
|
+ end
|
|
188
|
+ end);
|
|
189
|
+ host_module:hook("muc-room-destroyed",function(event)
|
|
190
|
+ local room = event.room;
|
|
191
|
+ if room._data.lobbyroom then
|
|
192
|
+ room._data.lobbyroom:destroy(nil, 'Lobby room closed.');
|
|
193
|
+ room._data.lobbyroom = nil;
|
196
|
194
|
end
|
197
|
195
|
end);
|
198
|
196
|
host_module:hook("muc-disco#info", function (event)
|
199
|
|
- if (event.room._data.lobbyroom) then
|
|
197
|
+ local room = event.room;
|
|
198
|
+ if (room._data.lobbyroom and room:get_members_only()) then
|
200
|
199
|
table.insert(event.form, {
|
201
|
200
|
name = "muc#roominfo_lobbyroom";
|
202
|
201
|
label = "Lobby room jid";
|
203
|
202
|
value = "";
|
204
|
203
|
});
|
205
|
|
- event.formdata["muc#roominfo_lobbyroom"] = event.room._data.lobbyroom;
|
|
204
|
+ event.formdata["muc#roominfo_lobbyroom"] = room._data.lobbyroom.jid;
|
206
|
205
|
end
|
207
|
206
|
end);
|
208
|
207
|
|
209
|
208
|
host_module:hook('muc-occupant-pre-join', function (event)
|
210
|
209
|
local room, stanza = event.room, event.stanza;
|
211
|
210
|
|
212
|
|
- if is_healthcheck_room(room.jid) then
|
|
211
|
+ if is_healthcheck_room(room.jid) or not room:get_members_only() then
|
213
|
212
|
return;
|
214
|
213
|
end
|
215
|
214
|
|
|
@@ -218,28 +217,42 @@ process_host_module(main_muc_component_config, function(host_module, host)
|
218
|
217
|
return;
|
219
|
218
|
end
|
220
|
219
|
|
221
|
|
- local password = join:get_child_text("lobbySharedPassword");
|
222
|
|
- if password and event.room.lobby_password and password == room.lobby_password then
|
223
|
|
- local invitee = event.stanza.attr.from;
|
|
220
|
+ local invitee = event.stanza.attr.from;
|
|
221
|
+ local invitee_bare_jid = jid_bare(invitee);
|
|
222
|
+ local _, invitee_domain = jid_split(invitee);
|
|
223
|
+ local whitelistJoin = false;
|
|
224
|
+
|
|
225
|
+ -- whitelist participants
|
|
226
|
+ if whitelist:contains(invitee_domain) or whitelist:contains(invitee_bare_jid) then
|
|
227
|
+ whitelistJoin = true;
|
|
228
|
+ end
|
|
229
|
+
|
|
230
|
+ local password = join:get_child_text('password', MUC_NS);
|
|
231
|
+ if password and room:get_password() and password == room:get_password() then
|
|
232
|
+ whitelistJoin = true;
|
|
233
|
+ end
|
|
234
|
+
|
|
235
|
+ if whitelistJoin then
|
224
|
236
|
local affiliation = room:get_affiliation(invitee);
|
225
|
237
|
if not affiliation or affiliation == 0 then
|
226
|
238
|
event.occupant.role = 'participant';
|
227
|
|
- room:set_affiliation(true, jid_bare(invitee), "member");
|
|
239
|
+ room:set_affiliation(true, invitee_bare_jid, "member");
|
228
|
240
|
room:save();
|
|
241
|
+
|
|
242
|
+ return;
|
229
|
243
|
end
|
|
244
|
+ end
|
230
|
245
|
|
231
|
246
|
-- we want to add the custom lobbyroom field to fill in the lobby room jid
|
232
|
|
- elseif room._data.members_only then
|
233
|
|
- local invitee = event.stanza.attr.from;
|
234
|
|
- local affiliation = room:get_affiliation(invitee);
|
235
|
|
- if not affiliation or affiliation == 'none' then
|
236
|
|
- local reply = st.error_reply(stanza, 'auth', 'registration-required'):up();
|
237
|
|
- reply.tags[1].attr.code = '407';
|
238
|
|
- reply:tag('x', {xmlns = MUC_NS}):up();
|
239
|
|
- reply:tag('lobbyroom'):text(room._data.lobbyroom);
|
240
|
|
- event.origin.send(reply:tag('x', {xmlns = MUC_NS}));
|
241
|
|
- return true;
|
242
|
|
- end
|
|
247
|
+ local invitee = event.stanza.attr.from;
|
|
248
|
+ local affiliation = room:get_affiliation(invitee);
|
|
249
|
+ if not affiliation or affiliation == 'none' then
|
|
250
|
+ local reply = st.error_reply(stanza, 'auth', 'registration-required'):up();
|
|
251
|
+ reply.tags[1].attr.code = '407';
|
|
252
|
+ reply:tag('x', {xmlns = MUC_NS}):up();
|
|
253
|
+ reply:tag('lobbyroom'):text(room._data.lobbyroom.jid);
|
|
254
|
+ event.origin.send(reply:tag('x', {xmlns = MUC_NS}));
|
|
255
|
+ return true;
|
243
|
256
|
end
|
244
|
257
|
end, -4); -- the default hook on members_only module is on -5
|
245
|
258
|
end);
|