moduleapi: Fix handling of replies to :send_iq from internal modules
authorKim Alvefur <zash@zash.se>
Sun, 22 Mar 2020 22:32:26 +0100
changeset 10709 2cffb5ce9f7a
parent 10708 06307833684b
child 10710 0230ceecb8a9
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.
core/moduleapi.lua
--- 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 ()