Diff

mod_rest/mod_rest.lua @ 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
parent 3843:c065b7670c89
child 3861:ede3d1724dd1
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