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 perform_bookmarks2 = disco
29 .features
30 .contains(&String::from("urn:xmpp:bookmarks:1#compat"));
31
32 if perform_bookmarks2 {
33 let iq = Iq::from_get("bookmarks", PubSub::Items(Items::new(ns::BOOKMARKS2))).into();
35 let _ = agent.client.send_stanza(iq).await;
36 } else {
37 let iq = Iq::from_get(
39 "bookmarks-legacy",
40 PrivateXMLQuery {
41 storage: bookmarks::Storage::new(),
42 },
43 )
44 .into();
45 let _ = agent.client.send_stanza(iq).await;
46 }
47 } else {
48 info!("Ignored disco#info response from {}", from);
49 }
50}