Mercurial > prosody-hg
comparison plugins/muc/muc.lib.lua @ 1745:15039fac3693
MUC: Some fixes for minor bugs in IQ handling.
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Mon, 07 Sep 2009 20:35:09 +0500 |
| parents | 265863a5612b |
| children | 3c60081ca10a |
comparison
equal
deleted
inserted
replaced
| 1744:265863a5612b | 1745:15039fac3693 |
|---|---|
| 307 end | 307 end |
| 308 end | 308 end |
| 309 | 309 |
| 310 function room_mt:handle_to_room(origin, stanza) -- presence changes and groupchat messages, along with disco/etc | 310 function room_mt:handle_to_room(origin, stanza) -- presence changes and groupchat messages, along with disco/etc |
| 311 local type = stanza.attr.type; | 311 local type = stanza.attr.type; |
| 312 if stanza.name == "iq" and type == "get" then -- disco requests | 312 local xmlns = stanza.tags[1] and stanza.tags[1].attr.xmlns; |
| 313 local xmlns = stanza.tags[1].attr.xmlns; | 313 if stanza.name == "iq" and type == "get" and xmlns ~= "http://jabber.org/protocol/muc#admin" then -- disco requests |
| 314 if xmlns == "http://jabber.org/protocol/disco#info" then | 314 if xmlns == "http://jabber.org/protocol/disco#info" then |
| 315 origin.send(room_get_disco_info(self, stanza)); | 315 origin.send(room_get_disco_info(self, stanza)); |
| 316 elseif xmlns == "http://jabber.org/protocol/disco#items" then | 316 elseif xmlns == "http://jabber.org/protocol/disco#items" then |
| 317 origin.send(room_get_disco_items(self, stanza)); | 317 origin.send(room_get_disco_items(self, stanza)); |
| 318 else | 318 else |
| 319 origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); | 319 origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); |
| 320 end | 320 end |
| 321 elseif stanza.name == "iq" and stanza.tags[1].attr.xmlns == "http://jabber.org/protocol/muc#admin" then | 321 elseif stanza.name == "iq" and xmlns == "http://jabber.org/protocol/muc#admin" then |
| 322 local actor = stanza.attr.from; | 322 local actor = stanza.attr.from; |
| 323 local affiliation = self:get_affiliation(actor); | 323 local affiliation = self:get_affiliation(actor); |
| 324 local current_nick = self._jid_nick[actor]; | 324 local current_nick = self._jid_nick[actor]; |
| 325 local role = current_nick and self._occupants[current_nick].role or self:get_default_role(affiliation); | 325 local role = current_nick and self._occupants[current_nick].role or self:get_default_role(affiliation); |
| 326 local item = stanza.tags[1] and stanza.tags[1].tags[1]; | 326 local item = stanza.tags[1].tags[1]; |
| 327 if item and item.name == "item" then | 327 if item and item.name == "item" then |
| 328 if type == "set" then | 328 if type == "set" then |
| 329 local callback = function() origin.send(st.reply(stanza)); end | 329 local callback = function() origin.send(st.reply(stanza)); end |
| 330 if item.attr.affiliation and item.attr.jid and not item.attr.role and not item.attr.nick then | 330 if item.attr.affiliation and item.attr.jid and not item.attr.role and not item.attr.nick then |
| 331 local success, errtype, err = self:set_affiliation(actor, item.attr.jid, item.attr.affiliation, callback); | 331 local success, errtype, err = self:set_affiliation(actor, item.attr.jid, item.attr.affiliation, callback); |
| 332 if not success then origin.send(st.error_reply(stanza, errtype, err)); end | 332 if not success then origin.send(st.error_reply(stanza, errtype, err)); end |
| 333 elseif item.attr.role and item.attr.nick and not item.attr.affiliation and not item.attr.jid then | 333 elseif item.attr.role and item.attr.nick and not item.attr.affiliation then |
| 334 local success, errtype, err = self:set_role(actor, item.attr.nick, item.attr.role, callback); | 334 local success, errtype, err = self:set_role(actor, self.jid.."/"..item.attr.nick, item.attr.role, callback); |
| 335 if not success then origin.send(st.error_reply(stanza, errtype, err)); end | 335 if not success then origin.send(st.error_reply(stanza, errtype, err)); end |
| 336 else | 336 else |
| 337 origin.send(st.error_reply(stanza, "cancel", "bad-request")); | 337 origin.send(st.error_reply(stanza, "cancel", "bad-request")); |
| 338 end | 338 end |
| 339 elseif type == "get" then | 339 elseif type == "get" then |
