|
@@ -7,6 +7,7 @@ local st = require "util.stanza";
|
7
|
7
|
local get_room_from_jid = module:require "util".get_room_from_jid;
|
8
|
8
|
local wrap_async_run = module:require "util".wrap_async_run;
|
9
|
9
|
local timer = require "util.timer";
|
|
10
|
+local MUC_NS = "http://jabber.org/protocol/muc";
|
10
|
11
|
|
11
|
12
|
-- Options
|
12
|
13
|
local poltergeist_component
|
|
@@ -200,12 +201,12 @@ end);
|
200
|
201
|
-- @param avatar the avatar to use for the new occupant (optional)
|
201
|
202
|
-- @param status the initial status to use for the new occupant (optional)
|
202
|
203
|
function create_poltergeist_occupant(room, nick, name, avatar, status)
|
203
|
|
- log("debug", "create_poltergeist_occupant %s:", nick);
|
|
204
|
+ log("debug", "create_poltergeist_occupant %s", nick);
|
204
|
205
|
-- Join poltergeist occupant to room, with the invited JID as their nick
|
205
|
206
|
local join_presence = st.presence({
|
206
|
207
|
to = room.jid.."/"..nick,
|
207
|
208
|
from = poltergeist_component.."/"..nick
|
208
|
|
- }):tag("x", { xmlns = "http://jabber.org/protocol/muc" }):up();
|
|
209
|
+ }):tag("x", { xmlns = MUC_NS }):up();
|
209
|
210
|
|
210
|
211
|
if (name) then
|
211
|
212
|
join_presence:tag(
|
|
@@ -219,6 +220,13 @@ function create_poltergeist_occupant(room, nick, name, avatar, status)
|
219
|
220
|
join_presence:tag("status"):text(status):up();
|
220
|
221
|
end
|
221
|
222
|
|
|
223
|
+ -- If the room has a password set, let the poltergeist enter using it
|
|
224
|
+ local room_password = room:get_password();
|
|
225
|
+ if room_password then
|
|
226
|
+ local join = join_presence:get_child("x", MUC_NS);
|
|
227
|
+ join:tag("password", { xmlns = MUC_NS }):text(room_password);
|
|
228
|
+ end
|
|
229
|
+
|
222
|
230
|
room:handle_first_presence(
|
223
|
231
|
prosody.hosts[poltergeist_component], join_presence);
|
224
|
232
|
|