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.
--- 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 ()