Comparison

plugins/muc/muc.lib.lua @ 5808:026367992a0f

mod_muc: Support for locking newly-created rooms until they are configured (enabled with muc_room_locking = true)
author Matthew Wild <mwild1@gmail.com>
date Fri, 30 Aug 2013 14:15:29 +0100
parent 5776:bd0ff8ae98a8
child 5854:16a2bb97c5f5
comparison
equal deleted inserted replaced
5807:d7212bd61b60 5808:026367992a0f
478 origin.send(reply:tag("x", {xmlns = "http://jabber.org/protocol/muc"})); 478 origin.send(reply:tag("x", {xmlns = "http://jabber.org/protocol/muc"}));
479 else 479 else
480 log("debug", "%s joining as %s", from, to); 480 log("debug", "%s joining as %s", from, to);
481 if not next(self._affiliations) then -- new room, no owners 481 if not next(self._affiliations) then -- new room, no owners
482 self._affiliations[jid_bare(from)] = "owner"; 482 self._affiliations[jid_bare(from)] = "owner";
483 if self.locked and not stanza:get_child("x", "http://jabber.org/protocol/muc") then
484 self.locked = nil; -- Older groupchat protocol doesn't lock
485 end
486 elseif self.locked then -- Deny entry
487 origin.send(st.error_reply(stanza, "cancel", "item-not-found"));
488 return;
483 end 489 end
484 local affiliation = self:get_affiliation(from); 490 local affiliation = self:get_affiliation(from);
485 local role = self:get_default_role(affiliation) 491 local role = self:get_default_role(affiliation)
486 if role then -- new occupant 492 if role then -- new occupant
487 if not is_merge then 493 if not is_merge then
498 self:broadcast_except_nick(pr, to); 504 self:broadcast_except_nick(pr, to);
499 end 505 end
500 pr:tag("status", {code='110'}):up(); 506 pr:tag("status", {code='110'}):up();
501 if self._data.whois == 'anyone' then 507 if self._data.whois == 'anyone' then
502 pr:tag("status", {code='100'}):up(); 508 pr:tag("status", {code='100'}):up();
509 end
510 if self.locked then
511 pr:tag("status", {code='201'}):up();
503 end 512 end
504 pr.attr.to = from; 513 pr.attr.to = from;
505 self:_route_stanza(pr); 514 self:_route_stanza(pr);
506 self:send_history(from, stanza); 515 self:send_history(from, stanza);
507 elseif not affiliation then -- registration required for entering members-only room 516 elseif not affiliation then -- registration required for entering members-only room
686 handle_option("historylength", "muc#roomconfig_historylength"); 695 handle_option("historylength", "muc#roomconfig_historylength");
687 handle_option("whois", "muc#roomconfig_whois", valid_whois); 696 handle_option("whois", "muc#roomconfig_whois", valid_whois);
688 handle_option("password", "muc#roomconfig_roomsecret"); 697 handle_option("password", "muc#roomconfig_roomsecret");
689 698
690 if self.save then self:save(true); end 699 if self.save then self:save(true); end
700 if self.locked then
701 module:fire_event("muc-room-unlocked", { room = self });
702 self.locked = nil;
703 end
691 origin.send(st.reply(stanza)); 704 origin.send(st.reply(stanza));
692 705
693 if next(changed) then 706 if next(changed) then
694 local msg = st.message({type='groupchat', from=self.jid}) 707 local msg = st.message({type='groupchat', from=self.jid})
695 :tag('x', {xmlns='http://jabber.org/protocol/muc#user'}):up() 708 :tag('x', {xmlns='http://jabber.org/protocol/muc#user'}):up()