Software /
code /
prosody
Comparison
core/moduleapi.lua @ 11821:a9ad287c3388
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.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 24 Sep 2021 20:12:16 +0200 |
parent | 11523:5f15ab7c6ae5 |
child | 11822:bdabb0425d77 |
comparison
equal
deleted
inserted
replaced
11820:0375ef78ed64 | 11821:a9ad287c3388 |
---|---|
437 end | 437 end |
438 | 438 |
439 local wrapped_origin = setmetatable({ | 439 local wrapped_origin = setmetatable({ |
440 -- XXX Needed in some cases for replies to work correctly when sending queries internally. | 440 -- XXX Needed in some cases for replies to work correctly when sending queries internally. |
441 send = function (reply) | 441 send = function (reply) |
442 resolve({ stanza = reply }); | 442 if reply.name == stanza.name and reply.attr.id == stanza.attr.id then |
443 resolve({ stanza = reply }); | |
444 end | |
445 return (origin or hosts[self.host]).send(reply) | |
443 end; | 446 end; |
444 }, { | 447 }, { |
445 __index = origin or hosts[self.host]; | 448 __index = origin or hosts[self.host]; |
446 }); | 449 }); |
447 | 450 |