# HG changeset patch # User Waqas Hussain # Date 1252337709 -18000 # Node ID 15039fac3693b5a1ee75154839448a15a1da8987 # Parent 265863a5612bf01fe53fe34615290f8de579e6ee MUC: Some fixes for minor bugs in IQ handling. diff -r 265863a5612b -r 15039fac3693 plugins/muc/muc.lib.lua --- a/plugins/muc/muc.lib.lua Mon Sep 07 20:33:24 2009 +0500 +++ b/plugins/muc/muc.lib.lua Mon Sep 07 20:35:09 2009 +0500 @@ -309,8 +309,8 @@ function room_mt:handle_to_room(origin, stanza) -- presence changes and groupchat messages, along with disco/etc local type = stanza.attr.type; - if stanza.name == "iq" and type == "get" then -- disco requests - local xmlns = stanza.tags[1].attr.xmlns; + local xmlns = stanza.tags[1] and stanza.tags[1].attr.xmlns; + if stanza.name == "iq" and type == "get" and xmlns ~= "http://jabber.org/protocol/muc#admin" then -- disco requests if xmlns == "http://jabber.org/protocol/disco#info" then origin.send(room_get_disco_info(self, stanza)); elseif xmlns == "http://jabber.org/protocol/disco#items" then @@ -318,20 +318,20 @@ else origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); end - elseif stanza.name == "iq" and stanza.tags[1].attr.xmlns == "http://jabber.org/protocol/muc#admin" then + elseif stanza.name == "iq" and xmlns == "http://jabber.org/protocol/muc#admin" then local actor = stanza.attr.from; local affiliation = self:get_affiliation(actor); local current_nick = self._jid_nick[actor]; local role = current_nick and self._occupants[current_nick].role or self:get_default_role(affiliation); - local item = stanza.tags[1] and stanza.tags[1].tags[1]; + local item = stanza.tags[1].tags[1]; if item and item.name == "item" then if type == "set" then local callback = function() origin.send(st.reply(stanza)); end if item.attr.affiliation and item.attr.jid and not item.attr.role and not item.attr.nick then local success, errtype, err = self:set_affiliation(actor, item.attr.jid, item.attr.affiliation, callback); if not success then origin.send(st.error_reply(stanza, errtype, err)); end - elseif item.attr.role and item.attr.nick and not item.attr.affiliation and not item.attr.jid then - local success, errtype, err = self:set_role(actor, item.attr.nick, item.attr.role, callback); + elseif item.attr.role and item.attr.nick and not item.attr.affiliation then + local success, errtype, err = self:set_role(actor, self.jid.."/"..item.attr.nick, item.attr.role, callback); if not success then origin.send(st.error_reply(stanza, errtype, err)); end else origin.send(st.error_reply(stanza, "cancel", "bad-request"));