|
@@ -105,7 +105,7 @@ function notify_lobby_access(room, actor, jid, display_name, granted)
|
105
|
105
|
end
|
106
|
106
|
|
107
|
107
|
function filter_stanza(stanza)
|
108
|
|
- if not stanza.attr or not stanza.attr.from or not main_muc_service then
|
|
108
|
+ if not stanza.attr or not stanza.attr.from or not main_muc_service or not lobby_muc_service then
|
109
|
109
|
return stanza;
|
110
|
110
|
end
|
111
|
111
|
-- Allow self-presence (code=110)
|
|
@@ -117,13 +117,32 @@ function filter_stanza(stanza)
|
117
|
117
|
return stanza;
|
118
|
118
|
end
|
119
|
119
|
|
120
|
|
- -- check is an owner, only owners can receive the presence
|
121
|
|
- local room = main_muc_service.get_room_from_jid(jid_bare(node .. '@' .. main_muc_component_config));
|
122
|
|
- if not room or room.get_affiliation(room, stanza.attr.to) == 'owner' then
|
|
120
|
+ local lobby_room_jid = jid_bare(stanza.attr.from);
|
|
121
|
+ local lobby_room = lobby_muc_service.get_room_from_jid(lobby_room_jid);
|
|
122
|
+ if not lobby_room then
|
|
123
|
+ module:log('warn', 'No lobby room found %s', lobby_room_jid);
|
123
|
124
|
return stanza;
|
124
|
125
|
end
|
125
|
126
|
|
126
|
|
- return nil;
|
|
127
|
+ local is_to_moderator = lobby_room:get_affiliation(stanza.attr.to) == 'owner';
|
|
128
|
+ local from_occupant = lobby_room:get_occupant_by_nick(stanza.attr.from);
|
|
129
|
+ if not from_occupant then
|
|
130
|
+ if is_to_moderator then
|
|
131
|
+ return stanza;
|
|
132
|
+ end
|
|
133
|
+
|
|
134
|
+ module:log('warn', 'No lobby occupant found %s', stanza.attr.from);
|
|
135
|
+ return nil;
|
|
136
|
+ end
|
|
137
|
+
|
|
138
|
+ local from_real_jid;
|
|
139
|
+ for real_jid in from_occupant:each_session() do
|
|
140
|
+ from_real_jid = real_jid;
|
|
141
|
+ end
|
|
142
|
+
|
|
143
|
+ if is_to_moderator and lobby_room:get_affiliation(from_real_jid) ~= 'owner' then
|
|
144
|
+ return stanza;
|
|
145
|
+ end
|
127
|
146
|
elseif stanza.name == 'iq' and stanza:get_child('query', DISCO_INFO_NS) then
|
128
|
147
|
-- allow disco info from the lobby component
|
129
|
148
|
return stanza;
|
|
@@ -139,7 +158,8 @@ function filter_session(session)
|
139
|
158
|
filters.add_filter(session, 'stanzas/out', filter_stanza, -1);
|
140
|
159
|
end
|
141
|
160
|
|
142
|
|
-function attach_lobby_room(room)
|
|
161
|
+-- actor can be null if called from backend (another module using hook create-lobby-room)
|
|
162
|
+function attach_lobby_room(room, actor)
|
143
|
163
|
local node = jid_split(room.jid);
|
144
|
164
|
local lobby_room_jid = node .. '@' .. lobby_muc_component_config;
|
145
|
165
|
if not lobby_muc_service.get_room_from_jid(lobby_room_jid) then
|
|
@@ -149,7 +169,7 @@ function attach_lobby_room(room)
|
149
|
169
|
-- which can leave the room with no occupants and it will be destroyed and we want to
|
150
|
170
|
-- avoid lobby destroy while it is enabled
|
151
|
171
|
new_room:set_persistent(true);
|
152
|
|
- module:log("debug","Lobby room jid = %s created",lobby_room_jid);
|
|
172
|
+ module:log("info","Lobby room jid = %s created from:%s", lobby_room_jid, actor);
|
153
|
173
|
new_room.main_room = room;
|
154
|
174
|
room._data.lobbyroom = new_room.jid;
|
155
|
175
|
room:save(true);
|
|
@@ -278,7 +298,7 @@ process_host_module(main_muc_component_config, function(host_module, host)
|
278
|
298
|
end
|
279
|
299
|
local members_only = event.fields['muc#roomconfig_membersonly'] and true or nil;
|
280
|
300
|
if members_only then
|
281
|
|
- local lobby_created = attach_lobby_room(room);
|
|
301
|
+ local lobby_created = attach_lobby_room(room, actor);
|
282
|
302
|
if lobby_created then
|
283
|
303
|
event.status_codes['104'] = true;
|
284
|
304
|
notify_lobby_enabled(room, actor, true);
|
|
@@ -382,7 +402,6 @@ end);
|
382
|
402
|
function handle_create_lobby(event)
|
383
|
403
|
local room = event.room;
|
384
|
404
|
room:set_members_only(true);
|
385
|
|
- module:log("info","Set room jid = %s as members only",room.jid);
|
386
|
405
|
attach_lobby_room(room)
|
387
|
406
|
end
|
388
|
407
|
|