1use tokio_xmpp::{
8 jid::Jid,
9 parsers::{
10 bookmarks,
11 disco::DiscoInfoResult,
12 iq::Iq,
13 ns,
14 private::Query as PrivateXMLQuery,
15 pubsub::pubsub::{Items, PubSub},
16 },
17};
18
19use crate::Agent;
20
21pub async fn handle_disco_info_result(agent: &mut Agent, disco: DiscoInfoResult, from: Jid) {
22 if from == agent.client.bound_jid().unwrap().to_bare() && agent.awaiting_disco_bookmarks_type {
24 info!("Received disco info about bookmarks type");
25 agent.awaiting_disco_bookmarks_type = false;
28 let mut perform_bookmarks2 = false;
29 for feature in disco.features {
30 if feature.var == "urn:xmpp:bookmarks:1#compat" {
31 perform_bookmarks2 = true;
32 }
33 }
34
35 if perform_bookmarks2 {
36 let iq = Iq::from_get("bookmarks", PubSub::Items(Items::new(ns::BOOKMARKS2))).into();
38 let _ = agent.client.send_stanza(iq).await;
39 } else {
40 let iq = Iq::from_get(
42 "bookmarks-legacy",
43 PrivateXMLQuery {
44 storage: bookmarks::Storage::new(),
45 },
46 )
47 .into();
48 let _ = agent.client.send_stanza(iq).await;
49 }
50 } else {
51 unimplemented!("Ignored disco#info response from {}", from);
52 }
53}