plugins/mod_muc.lua

changeset 834
596a6b425eb9
parent 833
5da1130054d1
child 835
2a8bfb7dee77
equal deleted inserted replaced
833:5da1130054d1 834:596a6b425eb9
184 local pr = get_filtered_presence(stanza); 184 local pr = get_filtered_presence(stanza);
185 pr.attr.from = current_nick; 185 pr.attr.from = current_nick;
186 if type == "error" then -- error, kick em out! 186 if type == "error" then -- error, kick em out!
187 if current_nick then 187 if current_nick then
188 log("debug", "kicking %s from %s", current_nick, room); 188 log("debug", "kicking %s from %s", current_nick, room);
189 local data = rooms:get(room, current_nick); 189 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 presence')); -- send unavailable
190 data.role = 'none';
191 local pr = st.presence({type='unavailable', from=current_nick}):tag('status'):text('This participant is kicked from the room because he sent an error presence'):up()
192 broadcast_presence_stanza(room, pr);
193 rooms:remove(room, current_nick);
194 jid_nick:remove(from, room);
195 end 190 end
196 elseif type == "unavailable" then -- unavailable 191 elseif type == "unavailable" then -- unavailable
197 if current_nick then 192 if current_nick then
198 log("debug", "%s leaving %s", current_nick, room); 193 log("debug", "%s leaving %s", current_nick, room);
199 local data = rooms:get(room, current_nick); 194 local data = rooms:get(room, current_nick);
231 end 226 end
232 end 227 end
233 end 228 end
234 else -- possible rejoin 229 else -- possible rejoin
235 log("debug", "%s had connection replaced", current_nick); 230 log("debug", "%s had connection replaced", current_nick);
236 local pr_ = st.presence({type='unavailable', from=from, to=current_nick}):tag('status'):text('Replaced by new connection'); 231 handle_to_occupant(origin, st.presence({type='unavailable', from=from, to=to}):tag('status'):text('Replaced by new connection')); -- send unavailable
237 handle_to_occupant(origin, pr_); -- send unavailable
238 handle_to_occupant(origin, stanza); -- resend available 232 handle_to_occupant(origin, stanza); -- resend available
239 end 233 end
240 else -- enter room 234 else -- enter room
241 local new_nick = to; 235 local new_nick = to;
242 if rooms:get(room, to) then 236 if rooms:get(room, to) then
289 elseif not current_nick then -- not in room 283 elseif not current_nick then -- not in room
290 origin.send(st.error_reply(stanza, "cancel", "not-acceptable")); 284 origin.send(st.error_reply(stanza, "cancel", "not-acceptable"));
291 elseif stanza.name == "message" and type == "groupchat" then -- groupchat messages not allowed in PM 285 elseif stanza.name == "message" and type == "groupchat" then -- groupchat messages not allowed in PM
292 origin.send(st.error_reply(stanza, "modify", "bad-request")); 286 origin.send(st.error_reply(stanza, "modify", "bad-request"));
293 elseif stanza.name == "message" and type == "error" then 287 elseif stanza.name == "message" and type == "error" then
294 if current_nick then 288 log("debug", "%s kicked from %s for sending an error message", current_nick, room);
295 log("debug", "%s kicked from %s for sending an error message", current_nick, room); 289 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
296 local data = rooms:get(room, to);
297 data.role = 'none';
298 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()
299 :tag("x", {xmlns='http://jabber.org/protocol/muc#user'})
300 :tag("item", {affiliation=data.affiliation, role=data.role}):up();
301 broadcast_presence_stanza(room, pr);
302 rooms:remove(room, to);
303 jid_nick:remove(from, room);
304 end
305 else -- private stanza 290 else -- private stanza
306 local o_data = rooms:get(room, to); 291 local o_data = rooms:get(room, to);
307 if o_data then 292 if o_data then
308 log("debug", "%s sent private stanza to %s (%s)", from, to, o_data.jid); 293 log("debug", "%s sent private stanza to %s (%s)", from, to, o_data.jid);
309 local jid = o_data.jid; 294 local jid = o_data.jid;

mercurial