From 7e181e31e0fdce18e0ce326f612edb2e9428fc13 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 22 Mar 2020 22:32:26 +0100 Subject: 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 | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/core/moduleapi.lua b/core/moduleapi.lua index 87c337d6..71239a0c 100644 --- a/core/moduleapi.lua +++ b/core/moduleapi.lua @@ -436,7 +436,16 @@ function api:send_iq(stanza, origin, timeout) 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 () -- cgit v1.2.3