1use tokio_xmpp::parsers::iq::{Iq, IqType};
8
9use crate::{Agent, Event};
10
11pub mod get;
12pub mod result;
13pub mod set;
14
15pub async fn handle_iq(agent: &mut Agent, iq: Iq) -> Vec<Event> {
16 let mut events = vec![];
17 let from = iq
18 .from
19 .clone()
20 .unwrap_or_else(|| agent.client.bound_jid().unwrap().to_bare().into());
21 if let IqType::Get(payload) = iq.payload {
22 get::handle_iq_get(agent, &mut events, from, iq.to, iq.id, payload).await;
23 } else if let IqType::Result(Some(payload)) = iq.payload {
24 result::handle_iq_result(agent, &mut events, from, iq.to, iq.id, payload).await;
25 } else if let IqType::Set(payload) = iq.payload {
26 set::handle_iq_set(agent, &mut events, from, iq.to, iq.id, payload).await;
27 }
28 events
29}