Changeset

10705:2cffb5ce9f7a

moduleapi: Fix handling of replies to :send_iq from internal modules Unclear exactly why, but replies to some queries to local modules would be discarded by stanza_router. This appears to fix it.
author Kim Alvefur <zash@zash.se>
date Sun, 22 Mar 2020 22:32:26 +0100
parents 10704:06307833684b
children 10706:0230ceecb8a9
files core/moduleapi.lua
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/core/moduleapi.lua	Sun Mar 29 22:12:42 2020 +0200
+++ b/core/moduleapi.lua	Sun Mar 22 22:32:26 2020 +0100
@@ -436,7 +436,16 @@
 			return;
 		end
 
-		self:send(stanza, origin);
+		local wrapped_origin = setmetatable({
+				-- XXX Needed in some cases for replies to work correctly when sending queries internally.
+				send = function (stanza)
+					resolve({ stanza = stanza });
+				end;
+			}, {
+				__index = origin or hosts[self.host];
+			});
+
+		self:send(stanza, wrapped_origin);
 	end);
 
 	p:finally(function ()