aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-09-24 20:12:16 +0200
committerKim Alvefur <zash@zash.se>2021-09-24 20:12:16 +0200
commit73d73278960523d3a1d603d08a76a9fb72fc067d (patch)
tree34355c395a3e29ca1005b4c2d4cacd207a9fd552 /core
parent39cb7aabe06ba85b83f3fc28a727a53b4c69d375 (diff)
downloadprosody-73d73278960523d3a1d603d08a76a9fb72fc067d.tar.gz
prosody-73d73278960523d3a1d603d08a76a9fb72fc067d.zip
core.moduleapi: Filter out unrelated direct replies to module:send_iq
This is primarily something that happens with an internal query to mod_mam, which calls origin.send() several times with results, leading to the first such result being treated as the final response and resolving the promise. Now, these responses pass trough to the underlying origin.send(), where they can be caught. Tricky but not impossible. For remote queries, it's even trickier, you would likely need to bind a resource or similar.
Diffstat (limited to 'core')
-rw-r--r--core/moduleapi.lua5
1 files changed, 4 insertions, 1 deletions
diff --git a/core/moduleapi.lua b/core/moduleapi.lua
index 59417027..a38a6076 100644
--- a/core/moduleapi.lua
+++ b/core/moduleapi.lua
@@ -439,7 +439,10 @@ function api:send_iq(stanza, origin, timeout)
local wrapped_origin = setmetatable({
-- XXX Needed in some cases for replies to work correctly when sending queries internally.
send = function (reply)
- resolve({ stanza = reply });
+ if reply.name == stanza.name and reply.attr.id == stanza.attr.id then
+ resolve({ stanza = reply });
+ end
+ return (origin or hosts[self.host]).send(reply)
end;
}, {
__index = origin or hosts[self.host];