tokio-xmpp: Ensure id is added only to stanza
The previous commit didn't fix a bug where @id would be added to elements that didn't need it / where it was invalid (e.g., stream management). Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
bc73af1e5e
commit
ae67949e7a
4 changed files with 25 additions and 19 deletions
|
|
@ -12,7 +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;
|
||||
use crate::xmpp_stream::add_stanza_id;
|
||||
|
||||
mod auth;
|
||||
|
||||
|
|
@ -54,11 +54,7 @@ impl Component {
|
|||
|
||||
/// Send stanza
|
||||
pub async fn send_stanza(&mut self, stanza: Element) -> Result<(), Error> {
|
||||
let mut el: Element = stanza;
|
||||
if el.attr("id").is_none() {
|
||||
el.set_attr("id", make_id());
|
||||
}
|
||||
self.send(el).await
|
||||
self.send(add_stanza_id(stanza, ns::COMPONENT_ACCEPT)).await
|
||||
}
|
||||
|
||||
/// End connection
|
||||
|
|
|
|||
Loading…
Reference in a new issue