Comparison

util/stanza.lua @ 2557:e5254ccd5ef8

util.stanza: stanza.error_reply(): Fix to put the correct namespace on <text>
author Matthew Wild <mwild1@gmail.com>
date Sun, 31 Jan 2010 19:27:52 +0000
parent 2526:401ff68413a1
child 2734:7941617b15f9
comparison
equal deleted inserted replaced
2556:50d1ba86a959 2557:e5254ccd5ef8
313 313
314 function reply(orig) 314 function reply(orig)
315 return stanza(orig.name, orig.attr and { to = orig.attr.from, from = orig.attr.to, id = orig.attr.id, type = ((orig.name == "iq" and "result") or orig.attr.type) }); 315 return stanza(orig.name, orig.attr and { to = orig.attr.from, from = orig.attr.to, id = orig.attr.id, type = ((orig.name == "iq" and "result") or orig.attr.type) });
316 end 316 end
317 317
318 function error_reply(orig, type, condition, message) 318 do
319 local t = reply(orig); 319 local xmpp_stanzas_attr = { xmlns = xmlns_stanzas };
320 t.attr.type = "error"; 320 function error_reply(orig, type, condition, message)
321 t:tag("error", {type = type}) 321 local t = reply(orig);
322 :tag(condition, {xmlns = "urn:ietf:params:xml:ns:xmpp-stanzas"}):up(); 322 t.attr.type = "error";
323 if (message) then t:tag("text"):text(message):up(); end 323 t:tag("error", {type = type}) --COMPAT: Some day xmlns:stanzas goes here
324 return t; -- stanza ready for adding app-specific errors 324 :tag(condition, xmpp_stanzas_attr):up();
325 if (message) then t:tag("text", xmpp_stanzas_attr):text(message):up(); end
326 return t; -- stanza ready for adding app-specific errors
327 end
325 end 328 end
326 329
327 function presence(attr) 330 function presence(attr)
328 return stanza("presence", attr); 331 return stanza("presence", attr);
329 end 332 end