changeset 3858:29c39876c4af

mod_rest: Ensure iq responses have type result if they're not errors
author Kim Alvefur <zash@zash.se>
date Sat, 25 Jan 2020 01:55:23 +0100
parents 8752e5b5dd08
children da3a0f055526
files mod_rest/mod_rest.lua
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mod_rest/mod_rest.lua	Sat Jan 25 01:31:49 2020 +0100
+++ b/mod_rest/mod_rest.lua	Sat Jan 25 01:55:23 2020 +0100
@@ -229,8 +229,14 @@
 					if parsed.name == "message" and parsed.attr.type == "groupchat" then
 						parsed.attr.to = jid.bare(stanza.attr.from);
 					end
-					if parsed.name == "iq" or parsed.attr.type == "error" then
+					if not stanza.attr.type and parsed:get_child("error") then
+						parsed.attr.type = "error";
+					end
+					if parsed.attr.type == "error" then
 						parsed.attr.id = stanza.attr.id;
+					elseif parsed.name == "iq" then
+						parsed.attr.id = stanza.attr.id;
+						parsed.attr.type = "result";
 					end
 					reply = parsed;
 				end