Diff

util/stanza.lua @ 10503:e25a1a9a6e7e

util.stanza: Accept util.error object to error_reply If we're moving towards util.error as the standard error container then this makes sense. This may allow for future extensibility without needing a lot of optional arguments.
author Kim Alvefur <zash@zash.se>
date Sat, 14 Dec 2019 22:47:41 +0100
parent 10446:5c2d1b13537c
child 10717:05e4645fc9b3
line wrap: on
line diff
--- a/util/stanza.lua	Sat Dec 14 22:43:12 2019 +0100
+++ b/util/stanza.lua	Sat Dec 14 22:47:41 2019 +0100
@@ -458,6 +458,9 @@
 	if t.attr.from == error_by then
 		error_by = nil;
 	end
+	if type(error_type) == "table" then -- an util.error or similar object
+		error_type, condition, error_message = error_type.type, error_type.condition, error_type.text;
+	end
 	t:tag("error", {type = error_type, by = error_by}) --COMPAT: Some day xmlns:stanzas goes here
 	:tag(condition, xmpp_stanzas_attr):up();
 	if error_message then t:text_tag("text", error_message, xmpp_stanzas_attr); end