tokio-xmpp: @id wasn't correctly added to every stanza
This commit moves the code adding @id to AsyncClient and SimpleClient, instead of on the lower level send_stanza helper, which seemed to only be used internally. Support is also added for Component. This removes the addition of @id on elements like <auth/> or <bind/>, which probably weren't required anyway? Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
6fa6deddcb
commit
bc73af1e5e
4 changed files with 20 additions and 11 deletions
|
|
@ -12,6 +12,7 @@ use super::happy_eyeballs::connect_to_host;
|
|||
use super::xmpp_codec::Packet;
|
||||
use super::xmpp_stream;
|
||||
use super::Error;
|
||||
use crate::xmpp_stream::make_id;
|
||||
|
||||
mod auth;
|
||||
|
||||
|
|
@ -53,7 +54,11 @@ impl Component {
|
|||
|
||||
/// Send stanza
|
||||
pub async fn send_stanza(&mut self, stanza: Element) -> Result<(), Error> {
|
||||
self.send(stanza).await
|
||||
let mut el: Element = stanza;
|
||||
if el.attr("id").is_none() {
|
||||
el.set_attr("id", make_id());
|
||||
}
|
||||
self.send(el).await
|
||||
}
|
||||
|
||||
/// End connection
|
||||
|
|
|
|||
Loading…
Reference in a new issue