Comparison

plugins/mod_muc.lua @ 812:1dbcf57154bd

MUC: Kick participants sending error messages to other participants
author Waqas Hussain <waqas20@gmail.com>
date Mon, 16 Feb 2009 20:05:58 +0500
parent 811:863046d84b56
child 813:ebfb904640d8
comparison
equal deleted inserted replaced
811:863046d84b56 812:1dbcf57154bd
327 elseif type ~= 'result' then -- bad type 327 elseif type ~= 'result' then -- bad type
328 origin.send(st.error_reply(stanza, "modify", "bad-request")); -- FIXME correct error? 328 origin.send(st.error_reply(stanza, "modify", "bad-request")); -- FIXME correct error?
329 end 329 end
330 elseif not current_nick then -- not in room 330 elseif not current_nick then -- not in room
331 origin.send(st.error_reply(stanza, "cancel", "not-acceptable")); 331 origin.send(st.error_reply(stanza, "cancel", "not-acceptable"));
332 elseif stanza.name == "message" and type == "groupchat" then 332 elseif stanza.name == "message" and type == "groupchat" then -- groupchat messages not allowed in PM
333 -- groupchat messages not allowed in PM
334 origin.send(st.error_reply(stanza, "modify", "bad-request")); 333 origin.send(st.error_reply(stanza, "modify", "bad-request"));
334 elseif stanza.name == "message" and type == "error" then
335 if current_nick then
336 local data = rooms:get(room, to);
337 data.role = 'none';
338 local pr = st.presence({type='unavailable', from=current_nick}):tag('status'):text('This participant is kicked from the room because he sent an error message to another occupant'):up()
339 :tag("x", {xmlns='http://jabber.org/protocol/muc#user'})
340 :tag("item", {affiliation=data.affiliation, role=data.role}):up();
341 broadcast_presence_stanza(room, pr);
342 rooms:remove(room, to);
343 jid_nick:remove(from, room);
344 end
335 else -- private stanza 345 else -- private stanza
336 local o_data = rooms:get(room, to); 346 local o_data = rooms:get(room, to);
337 if o_data then 347 if o_data then
338 stanza.attr.to, stanza.attr.from = o_data.jid, current_nick; 348 stanza.attr.to, stanza.attr.from = o_data.jid, current_nick;
339 core_route_stanza(component, stanza); 349 core_route_stanza(component, stanza);