aboutsummaryrefslogtreecommitdiffstats
path: root/util/stanza.lua
diff options
context:
space:
mode:
Diffstat (limited to 'util/stanza.lua')
-rw-r--r--util/stanza.lua10
1 files changed, 10 insertions, 0 deletions
diff --git a/util/stanza.lua b/util/stanza.lua
index 73f58747..85595664 100644
--- a/util/stanza.lua
+++ b/util/stanza.lua
@@ -123,6 +123,16 @@ function reply(orig)
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