util/stanza.lua
changeset 60 44800be871f5
parent 30 bcf539295f2d
child 62 9ec0d447cc9e
equal deleted inserted replaced
57:126b25079399 60:44800be871f5
   130 
   130 
   131 function reply(orig)
   131 function reply(orig)
   132 	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) });
   132 	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) });
   133 end
   133 end
   134 
   134 
       
   135 function error_reply(orig, type, condition, message, clone)
       
   136 	local r = reply(orig);
       
   137 	t.attr.type = "error";
       
   138 	-- TODO use clone
       
   139 	t:tag("error", {type = type})
       
   140 		:tag(condition, {xmlns = "urn:ietf:params:xml:ns:xmpp-stanzas"}):up();
       
   141 	if (message) then t:tag("text"):text(message):up(); end
       
   142 	return t; -- stanza ready for adding app-specific errors
       
   143 end
       
   144 
   135 function presence(attr)
   145 function presence(attr)
   136 	return stanza("presence", attr);
   146 	return stanza("presence", attr);
   137 end
   147 end
   138 
   148 
   139 return _M;
   149 return _M;