Procházet zdrojové kódy

Adds poltergeist support for locked rooms. (#2626)

master
Дамян Минков před 7 roky
rodič
revize
eb53944a4d
1 změnil soubory, kde provedl 10 přidání a 2 odebrání
  1. 10
    2
      resources/prosody-plugins/mod_muc_poltergeist.lua

+ 10
- 2
resources/prosody-plugins/mod_muc_poltergeist.lua Zobrazit soubor

7
 local get_room_from_jid = module:require "util".get_room_from_jid;
7
 local get_room_from_jid = module:require "util".get_room_from_jid;
8
 local wrap_async_run = module:require "util".wrap_async_run;
8
 local wrap_async_run = module:require "util".wrap_async_run;
9
 local timer = require "util.timer";
9
 local timer = require "util.timer";
10
+local MUC_NS = "http://jabber.org/protocol/muc";
10
 
11
 
11
 -- Options
12
 -- Options
12
 local poltergeist_component
13
 local poltergeist_component
200
 -- @param avatar the avatar to use for the new occupant (optional)
201
 -- @param avatar the avatar to use for the new occupant (optional)
201
 -- @param status the initial status to use for the new occupant (optional)
202
 -- @param status the initial status to use for the new occupant (optional)
202
 function create_poltergeist_occupant(room, nick, name, avatar, status)
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
     -- Join poltergeist occupant to room, with the invited JID as their nick
205
     -- Join poltergeist occupant to room, with the invited JID as their nick
205
     local join_presence = st.presence({
206
     local join_presence = st.presence({
206
         to = room.jid.."/"..nick,
207
         to = room.jid.."/"..nick,
207
         from = poltergeist_component.."/"..nick
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
     if (name) then
211
     if (name) then
211
         join_presence:tag(
212
         join_presence:tag(
219
         join_presence:tag("status"):text(status):up();
220
         join_presence:tag("status"):text(status):up();
220
     end
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
     room:handle_first_presence(
230
     room:handle_first_presence(
223
         prosody.hosts[poltergeist_component], join_presence);
231
         prosody.hosts[poltergeist_component], join_presence);
224
 
232
 

Načítá se…
Zrušit
Uložit