changeset 3798:9b4fd2553365

mod_rest: Handle receipt requests on message stanzas
author Kim Alvefur <zash@zash.se>
date Mon, 30 Dec 2019 05:18:52 +0100
parents ed5d7586a61e
children a1f1f703d604
files mod_rest/mod_rest.lua
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mod_rest/mod_rest.lua	Mon Dec 30 05:17:18 2019 +0100
+++ b/mod_rest/mod_rest.lua	Mon Dec 30 05:18:52 2019 +0100
@@ -120,6 +120,12 @@
 	local function handle_stanza(event)
 		local stanza, origin = event.stanza, event.origin;
 		local reply_needed = stanza.name == "iq";
+		local receipt;
+
+		if stanza.name == "message" and stanza.attr.id and stanza:get_child("urn:xmpp:receipts", "request") then
+			reply_needed = true;
+			receipt = st.stanza("received", { xmlns = "urn:xmpp:receipts", id = stanza.id });
+		end
 
 		http.request(rest_url, {
 				body = tostring(stanza),
@@ -179,6 +185,10 @@
 					end
 				end
 
+				if receipt then
+					reply:add_direct_child(receipt);
+				end
+
 				origin.send(reply);
 			end);