Comparison

plugins/muc/muc.lib.lua @ 1768:802c40384dd0

MUC: Don't kick on errors in private messages.
author Waqas Hussain <waqas20@gmail.com>
date Wed, 09 Sep 2009 20:32:37 +0500
parent 1764:c00d4ba8d2f3
child 1769:39865fbbb2f7
comparison
equal deleted inserted replaced
1767:649dd3439809 1768:802c40384dd0
293 end 293 end
294 elseif not current_nick and type ~= "error" and type ~= "result" then -- not in room 294 elseif not current_nick and type ~= "error" and type ~= "result" then -- not in room
295 origin.send(st.error_reply(stanza, "cancel", "not-acceptable")); 295 origin.send(st.error_reply(stanza, "cancel", "not-acceptable"));
296 elseif stanza.name == "message" and type == "groupchat" then -- groupchat messages not allowed in PM 296 elseif stanza.name == "message" and type == "groupchat" then -- groupchat messages not allowed in PM
297 origin.send(st.error_reply(stanza, "modify", "bad-request")); 297 origin.send(st.error_reply(stanza, "modify", "bad-request"));
298 elseif stanza.name == "message" and type == "error" and get_kickable_error(stanza) then
299 log("debug", "%s kicked from %s for sending an error message", current_nick, room);
300 self:handle_to_occupant(origin, st.presence({type='unavailable', from=from, to=to}):tag('status'):text('This participant is kicked from the room because he sent an error message to another occupant')); -- send unavailable
301 else -- private stanza 298 else -- private stanza
302 local o_data = self._occupants[to]; 299 local o_data = self._occupants[to];
303 if o_data then 300 if o_data then
304 log("debug", "%s sent private stanza to %s (%s)", from, to, o_data.jid); 301 log("debug", "%s sent private stanza to %s (%s)", from, to, o_data.jid);
305 local jid = o_data.jid; 302 local jid = o_data.jid;
444 self:set_subject(current_nick, subject); -- TODO use broadcast_message_stanza 441 self:set_subject(current_nick, subject); -- TODO use broadcast_message_stanza
445 else 442 else
446 self:broadcast_message(stanza, true); 443 self:broadcast_message(stanza, true);
447 end 444 end
448 end 445 end
446 elseif stanza.name == "message" and type == "error" and get_kickable_error(stanza) then
447 local current_nick = self._jid_nick[stanza.attr.from];
448 log("debug", "%s kicked from %s for sending an error message", current_nick, self.jid);
449 self:handle_to_occupant(origin, st.presence({type='unavailable', from=stanza.attr.from, to=stanza.attr.to})
450 :tag('status'):text('This participant is kicked from the room because he sent an error message to another occupant')); -- send unavailable
449 elseif stanza.name == "presence" then -- hack - some buggy clients send presence updates to the room rather than their nick 451 elseif stanza.name == "presence" then -- hack - some buggy clients send presence updates to the room rather than their nick
450 local to = stanza.attr.to; 452 local to = stanza.attr.to;
451 local current_nick = self._jid_nick[stanza.attr.from]; 453 local current_nick = self._jid_nick[stanza.attr.from];
452 if current_nick then 454 if current_nick then
453 stanza.attr.to = current_nick; 455 stanza.attr.to = current_nick;