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:
Maxime “pep” Buquet 2023-06-04 19:27:46 +02:00
commit ae67949e7a
No known key found for this signature in database
GPG key ID: DEDA74AEECA9D0F2
4 changed files with 25 additions and 19 deletions

View file

@ -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