xmpp-parsers: Remove Feature from disco#info

This was just a newtype for a String, but in general using it was harder
than without it.  This simplifies the public API.
This commit is contained in:
Link Mauve 2026-01-09 00:25:32 +01:00
commit 946d96d7c8
7 changed files with 23 additions and 40 deletions

View file

@ -11,7 +11,7 @@ use crate::{
Agent, ClientFeature, ClientType, Config, RoomNick,
jid::{BareJid, Jid, ResourceRef},
parsers::{
disco::{DiscoInfoResult, Feature, Identity},
disco::{DiscoInfoResult, Identity},
ns,
},
tokio_xmpp::{Client as TokioXmppClient, connect::ServerConnector, xmlstream::Timeouts},
@ -107,15 +107,15 @@ impl<C: ServerConnector> ClientBuilder<'_, C> {
"en",
self.config.disco.1.to_string(),
)];
let mut features = vec![Feature::new(ns::DISCO_INFO)];
let mut features = vec![String::from(ns::DISCO_INFO)];
#[cfg(feature = "avatars")]
{
if self.features.contains(&ClientFeature::Avatars) {
features.push(Feature::new(format!("{}+notify", ns::AVATAR_METADATA)));
features.push(format!("{}+notify", ns::AVATAR_METADATA));
}
}
if self.features.contains(&ClientFeature::JoinRooms) {
features.push(Feature::new(format!("{}+notify", ns::BOOKMARKS2)));
features.push(format!("{}+notify", ns::BOOKMARKS2));
}
DiscoInfoResult {
node: None,

View file

@ -25,12 +25,9 @@ pub async fn handle_disco_info_result(agent: &mut Agent, disco: DiscoInfoResult,
// Trigger bookmarks query
// TODO: only send this when the JoinRooms feature is enabled.
agent.awaiting_disco_bookmarks_type = false;
let mut perform_bookmarks2 = false;
for feature in disco.features {
if feature.var == "urn:xmpp:bookmarks:1#compat" {
perform_bookmarks2 = true;
}
}
let perform_bookmarks2 = disco
.features
.contains(&String::from("urn:xmpp:bookmarks:1#compat"));
if perform_bookmarks2 {
// XEP-0402 bookmarks (modern)