util/stanza.lua
changeset 70 a6c00467a3f8
parent 62 9ec0d447cc9e
child 90 da468ed49a7b
equal deleted inserted replaced
69:5b664c8fef86 70:a6c00467a3f8
   122 function reply(orig)
   122 function reply(orig)
   123 	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 nil) });
   123 	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 nil) });
   124 end
   124 end
   125 
   125 
   126 function error_reply(orig, type, condition, message, clone)
   126 function error_reply(orig, type, condition, message, clone)
   127 	local r = reply(orig);
   127 	local t = reply(orig);
   128 	t.attr.type = "error";
   128 	t.attr.type = "error";
   129 	-- TODO use clone
   129 	-- TODO use clone
   130 	t:tag("error", {type = type})
   130 	t:tag("error", {type = type})
   131 		:tag(condition, {xmlns = "urn:ietf:params:xml:ns:xmpp-stanzas"}):up();
   131 		:tag(condition, {xmlns = "urn:ietf:params:xml:ns:xmpp-stanzas"}):up();
   132 	if (message) then t:tag("text"):text(message):up(); end
   132 	if (message) then t:tag("text"):text(message):up(); end