util/stanza.lua

changeset 1151
8096941b6734
parent 964
3296db2ad4a0
child 1415
957a81b72cb2
equal deleted inserted replaced
1150:d71a8f28f18b 1151:8096941b6734
256 256
257 function reply(orig) 257 function reply(orig)
258 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) }); 258 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) });
259 end 259 end
260 260
261 function error_reply(orig, type, condition, message, clone) 261 function error_reply(orig, type, condition, message)
262 local t = reply(orig); 262 local t = reply(orig);
263 t.attr.type = "error"; 263 t.attr.type = "error";
264 -- TODO use clone
265 t:tag("error", {type = type}) 264 t:tag("error", {type = type})
266 :tag(condition, {xmlns = "urn:ietf:params:xml:ns:xmpp-stanzas"}):up(); 265 :tag(condition, {xmlns = "urn:ietf:params:xml:ns:xmpp-stanzas"}):up();
267 if (message) then t:tag("text"):text(message):up(); end 266 if (message) then t:tag("text"):text(message):up(); end
268 return t; -- stanza ready for adding app-specific errors 267 return t; -- stanza ready for adding app-specific errors
269 end 268 end

mercurial