Diff

util/stanza.lua @ 60:44800be871f5

User registration, etc (jabber:iq:register)
author Waqas Hussain <waqas20@gmail.com>
date Sun, 05 Oct 2008 04:55:45 +0500
parent 30:bcf539295f2d
child 62:9ec0d447cc9e
line wrap: on
line diff
--- a/util/stanza.lua	Sat Oct 04 17:59:32 2008 +0100
+++ b/util/stanza.lua	Sun Oct 05 04:55:45 2008 +0500
@@ -132,6 +132,16 @@
 	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) });
 end
 
+function error_reply(orig, type, condition, message, clone)
+	local r = reply(orig);
+	t.attr.type = "error";
+	-- TODO use clone
+	t:tag("error", {type = type})
+		:tag(condition, {xmlns = "urn:ietf:params:xml:ns:xmpp-stanzas"}):up();
+	if (message) then t:tag("text"):text(message):up(); end
+	return t; -- stanza ready for adding app-specific errors
+end
+
 function presence(attr)
 	return stanza("presence", attr);
 end