Changeset

4699:a8af632daf48

mod_rest: Support returning multiple replies in an <xmpp> container Allows retrieving MAM results and possibly other things.
author Kim Alvefur <zash@zash.se>
date Wed, 29 Sep 2021 00:26:44 +0200
parents 4698:4157773ed4d3
children 4700:f821eeac0e50
files mod_rest/mod_rest.lua
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mod_rest/mod_rest.lua	Sat Sep 25 11:43:31 2021 +0000
+++ b/mod_rest/mod_rest.lua	Wed Sep 29 00:26:44 2021 +0200
@@ -293,8 +293,9 @@
 	end
 
 	if payload.name == "iq" then
+		local responses = st.stanza("xmpp");
 		function origin.send(stanza)
-			module:send(stanza);
+			responses:add_direct_child(stanza);
 		end
 
 		if payload.attr.type ~= "get" and payload.attr.type ~= "set" then
@@ -307,6 +308,9 @@
 			function (result)
 				module:log("debug", "Sending[rest]: %s", result.stanza:top_tag());
 				response.headers.content_type = send_type;
+				if responses[2] then
+					return encode(send_type, responses);
+				end
 				return encode(send_type, result.stanza);
 			end,
 			function (error)