Comparison

plugins/muc/muc.lib.lua @ 1818:a394e0bd4847

MUC: Added legacy error codes to nickname conflict presence errors.
author Waqas Hussain <waqas20@gmail.com>
date Fri, 25 Sep 2009 03:21:57 +0500
parent 1808:e164fdb2d18f
child 1819:ed1911be26c7
comparison
equal deleted inserted replaced
1817:5a86a9826b96 1818:a394e0bd4847
238 self._occupants[current_nick].sessions[from] = pr; 238 self._occupants[current_nick].sessions[from] = pr;
239 self:broadcast_presence(pr); 239 self:broadcast_presence(pr);
240 else -- change nick 240 else -- change nick
241 if self._occupants[to] then 241 if self._occupants[to] then
242 log("debug", "%s couldn't change nick", current_nick); 242 log("debug", "%s couldn't change nick", current_nick);
243 origin.send(st.error_reply(stanza, "cancel", "conflict"):tag("x", {xmlns = "http://jabber.org/protocol/muc"})); 243 local reply = st.error_reply(stanza, "cancel", "conflict"):up();
244 reply.tags[1].attr.code = "409";
245 origin.send(reply:tag("x", {xmlns = "http://jabber.org/protocol/muc"}));
244 else 246 else
245 local data = self._occupants[current_nick]; 247 local data = self._occupants[current_nick];
246 local to_nick = select(3, jid_split(to)); 248 local to_nick = select(3, jid_split(to));
247 if to_nick then 249 if to_nick then
248 log("debug", "%s (%s) changing nick to %s", current_nick, data.jid, to); 250 log("debug", "%s (%s) changing nick to %s", current_nick, data.jid, to);
270 if self._occupants[to] then 272 if self._occupants[to] then
271 new_nick = nil; 273 new_nick = nil;
272 end 274 end
273 if not new_nick then 275 if not new_nick then
274 log("debug", "%s couldn't join due to nick conflict: %s", from, to); 276 log("debug", "%s couldn't join due to nick conflict: %s", from, to);
275 origin.send(st.error_reply(stanza, "cancel", "conflict"):tag("x", {xmlns = "http://jabber.org/protocol/muc"})); 277 local reply = st.error_reply(stanza, "cancel", "conflict"):up();
278 reply.tags[1].attr.code = "409";
279 origin.send(reply:tag("x", {xmlns = "http://jabber.org/protocol/muc"}));
276 else 280 else
277 log("debug", "%s joining as %s", from, to); 281 log("debug", "%s joining as %s", from, to);
278 if not next(self._affiliations) then -- new room, no owners 282 if not next(self._affiliations) then -- new room, no owners
279 self._affiliations[jid_bare(from)] = "owner"; 283 self._affiliations[jid_bare(from)] = "owner";
280 end 284 end