mod_c2s, mod_s2s: Set session.encrypted as session.secure does not allways mean encry...
[prosody.git] / plugins / muc / muc.lib.lua
index 8800640f40edf4458caec256e7828e80983ee180..1b76ec94ad391bbed5f3c469c5bf757bbd608b2b 100644 (file)
@@ -202,7 +202,7 @@ function room_mt:get_disco_info(stanza)
                :tag("feature", {var=self._data.whois ~= "anyone" and "muc_semianonymous" or "muc_nonanonymous"}):up()
                :add_child(dataform.new({
                        { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/muc#roominfo" },
-                       { name = "muc#roominfo_description", label = "Description"},
+                       { name = "muc#roominfo_description", label = "Description", value = "" },
                        { name = "muc#roominfo_occupants", label = "Number of occupants", value = tostring(count) }
                }):form({["muc#roominfo_description"] = self:get_description()}, 'result'))
        ;
@@ -480,6 +480,12 @@ function room_mt:handle_to_occupant(origin, stanza) -- PM, vCards, etc
                                        log("debug", "%s joining as %s", from, to);
                                        if not next(self._affiliations) then -- new room, no owners
                                                self._affiliations[jid_bare(from)] = "owner";
+                                               if self.locked and not stanza:get_child("x", "http://jabber.org/protocol/muc") then
+                                                       self.locked = nil; -- Older groupchat protocol doesn't lock
+                                               end
+                                       elseif self.locked then -- Deny entry
+                                               origin.send(st.error_reply(stanza, "cancel", "item-not-found"));
+                                               return;
                                        end
                                        local affiliation = self:get_affiliation(from);
                                        local role = self:get_default_role(affiliation)
@@ -501,6 +507,9 @@ function room_mt:handle_to_occupant(origin, stanza) -- PM, vCards, etc
                                                if self._data.whois == 'anyone' then
                                                        pr:tag("status", {code='100'}):up();
                                                end
+                                               if self.locked then
+                                                       pr:tag("status", {code='201'}):up();
+                                               end
                                                pr.attr.to = from;
                                                self:_route_stanza(pr);
                                                self:send_history(from, stanza);
@@ -688,6 +697,10 @@ function room_mt:process_form(origin, stanza)
        handle_option("password", "muc#roomconfig_roomsecret");
 
        if self.save then self:save(true); end
+       if self.locked then
+               module:fire_event("muc-room-unlocked", { room = self });
+               self.locked = nil;
+       end
        origin.send(st.reply(stanza));
 
        if next(changed) then