comparison 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
parents c065b7670c89
children ede3d1724dd1
comparison
equal deleted inserted replaced
3857:8752e5b5dd08 3858:29c39876c4af
227 ["xml:lang"] = parsed.attr["xml:lang"], 227 ["xml:lang"] = parsed.attr["xml:lang"],
228 }; 228 };
229 if parsed.name == "message" and parsed.attr.type == "groupchat" then 229 if parsed.name == "message" and parsed.attr.type == "groupchat" then
230 parsed.attr.to = jid.bare(stanza.attr.from); 230 parsed.attr.to = jid.bare(stanza.attr.from);
231 end 231 end
232 if parsed.name == "iq" or parsed.attr.type == "error" then 232 if not stanza.attr.type and parsed:get_child("error") then
233 parsed.attr.type = "error";
234 end
235 if parsed.attr.type == "error" then
233 parsed.attr.id = stanza.attr.id; 236 parsed.attr.id = stanza.attr.id;
237 elseif parsed.name == "iq" then
238 parsed.attr.id = stanza.attr.id;
239 parsed.attr.type = "result";
234 end 240 end
235 reply = parsed; 241 reply = parsed;
236 end 242 end
237 243
238 if not reply then 244 if not reply then