diff --git a/tokio-xmpp/ChangeLog b/tokio-xmpp/ChangeLog index 26fb27f8..e7eca84d 100644 --- a/tokio-xmpp/ChangeLog +++ b/tokio-xmpp/ChangeLog @@ -6,8 +6,8 @@ Version NEXT: * Fixed: - Ignore missing "version" stream attribute for 0114 components. - Gate `AsRawFd` behind `ktls` feature to make Windows build work again. - - Implicitly use the `Client`'s bound JID on empty `to` in tokio-xmpp's - `IqResponseTracker`. + - Implicitly use the `Client`'s bound JID on empty `from` and `to` in + tokio-xmpp's `IqResponseTracker`. - Actually count inbound stream management stanzas (!657) instead of always sending h='0' in our ``. diff --git a/tokio-xmpp/src/client/iq.rs b/tokio-xmpp/src/client/iq.rs index 0227b175..453c481e 100644 --- a/tokio-xmpp/src/client/iq.rs +++ b/tokio-xmpp/src/client/iq.rs @@ -278,7 +278,7 @@ impl IqResponseTracker { /// Returns the IQ stanza unharmed if it is not an IQ response matching /// any request which is still being tracked. pub fn handle_iq(&self, iq: Iq) -> ControlFlow<(), Iq> { - let (from, to, id, payload) = match iq { + let (mut from, to, id, payload) = match iq { Iq::Error { from, to, @@ -294,6 +294,14 @@ impl IqResponseTracker { } => (from, to, id, IqResponse::Result(payload)), _ => return ControlFlow::Continue(iq), }; + + if from.is_none() { + // Implicitly setting None to the JID the tracker is active for in case the server + // doesn't. This ensures that the IQ can be matched in the map again. + let account_jid = self.account_jid.lock().unwrap(); + from = account_jid.clone().map(Jid::from); + } + let key = (from, id); let mut map = self.map.lock().unwrap(); match map.remove(&key) {