From 54ca5eb3155d1cfcadced7c0a3a405ce1d51ecf6 Mon Sep 17 00:00:00 2001 From: cel 🌸 Date: Mon, 24 Mar 2025 12:22:08 +0000 Subject: feat(stanza): xep-0203 --- stanza/src/client/presence.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'stanza/src/client/presence.rs') diff --git a/stanza/src/client/presence.rs b/stanza/src/client/presence.rs index 1603ace..ae38756 100644 --- a/stanza/src/client/presence.rs +++ b/stanza/src/client/presence.rs @@ -6,6 +6,9 @@ use peanuts::{ DeserializeError, Element, XML_NS, }; +#[cfg(feature = "xep_0203")] +use crate::xep_0203::Delay; + use super::{error::Error, XMLNS}; #[derive(Debug, Clone)] @@ -19,6 +22,8 @@ pub struct Presence { pub show: Option, pub status: Option, pub priority: Option, + #[cfg(feature = "xep_0203")] + pub delay: Option, // TODO: ##other // other: Vec, pub errors: Vec, @@ -40,6 +45,9 @@ impl FromElement for Presence { let priority = element.child_opt()?; let errors = element.children()?; + #[cfg(feature = "xep_0203")] + let delay = element.child_opt()?; + Ok(Presence { from, id, @@ -50,13 +58,15 @@ impl FromElement for Presence { status, priority, errors, + #[cfg(feature = "xep_0203")] + delay, }) } } impl IntoElement for Presence { fn builder(&self) -> peanuts::element::ElementBuilder { - Element::builder("presence", Some(XMLNS)) + let builder = Element::builder("presence", Some(XMLNS)) .push_attribute_opt("from", self.from.clone()) .push_attribute_opt("id", self.id.clone()) .push_attribute_opt("to", self.to.clone()) @@ -65,7 +75,12 @@ impl IntoElement for Presence { .push_child_opt(self.show) .push_child_opt(self.status.clone()) .push_child_opt(self.priority) - .push_children(self.errors.clone()) + .push_children(self.errors.clone()); + + #[cfg(feature = "xep_0203")] + let builder = builder.push_child_opt(self.delay.clone()); + + builder } } -- cgit