From eb53944a4da9c20f6afbbe31fd2d0b8fd46a64c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BC=D1=8F=D0=BD=20=D0=9C=D0=B8=D0=BD=D0=BA?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 19 Mar 2018 16:20:44 -0500 Subject: [PATCH] Adds poltergeist support for locked rooms. (#2626) --- resources/prosody-plugins/mod_muc_poltergeist.lua | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/resources/prosody-plugins/mod_muc_poltergeist.lua b/resources/prosody-plugins/mod_muc_poltergeist.lua index 0b18eee27..32a9aac2c 100644 --- a/resources/prosody-plugins/mod_muc_poltergeist.lua +++ b/resources/prosody-plugins/mod_muc_poltergeist.lua @@ -7,6 +7,7 @@ local st = require "util.stanza"; local get_room_from_jid = module:require "util".get_room_from_jid; local wrap_async_run = module:require "util".wrap_async_run; local timer = require "util.timer"; +local MUC_NS = "http://jabber.org/protocol/muc"; -- Options local poltergeist_component @@ -200,12 +201,12 @@ end); -- @param avatar the avatar to use for the new occupant (optional) -- @param status the initial status to use for the new occupant (optional) function create_poltergeist_occupant(room, nick, name, avatar, status) - log("debug", "create_poltergeist_occupant %s:", nick); + log("debug", "create_poltergeist_occupant %s", nick); -- Join poltergeist occupant to room, with the invited JID as their nick local join_presence = st.presence({ to = room.jid.."/"..nick, from = poltergeist_component.."/"..nick - }):tag("x", { xmlns = "http://jabber.org/protocol/muc" }):up(); + }):tag("x", { xmlns = MUC_NS }):up(); if (name) then join_presence:tag( @@ -219,6 +220,13 @@ function create_poltergeist_occupant(room, nick, name, avatar, status) join_presence:tag("status"):text(status):up(); end + -- If the room has a password set, let the poltergeist enter using it + local room_password = room:get_password(); + if room_password then + local join = join_presence:get_child("x", MUC_NS); + join:tag("password", { xmlns = MUC_NS }):text(room_password); + end + room:handle_first_presence( prosody.hosts[poltergeist_component], join_presence);