aboutsummaryrefslogtreecommitdiffstats
path: root/stanza/src/client/presence.rs
diff options
context:
space:
mode:
authorLibravatar cel 🌸 <cel@bunny.garden>2025-03-24 12:22:08 +0000
committerLibravatar cel 🌸 <cel@bunny.garden>2025-03-24 12:31:01 +0000
commit54ca5eb3155d1cfcadced7c0a3a405ce1d51ecf6 (patch)
tree49a59ebae7bd7b58caaa748a20b745397c37c2e3 /stanza/src/client/presence.rs
parent9f0a480bc4c6ee3ac8c707b05d40529afef0d78f (diff)
downloadluz-54ca5eb3155d1cfcadced7c0a3a405ce1d51ecf6.tar.gz
luz-54ca5eb3155d1cfcadced7c0a3a405ce1d51ecf6.tar.bz2
luz-54ca5eb3155d1cfcadced7c0a3a405ce1d51ecf6.zip
feat(stanza): xep-0203
Diffstat (limited to 'stanza/src/client/presence.rs')
-rw-r--r--stanza/src/client/presence.rs19
1 files changed, 17 insertions, 2 deletions
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<Show>,
pub status: Option<Status>,
pub priority: Option<Priority>,
+ #[cfg(feature = "xep_0203")]
+ pub delay: Option<Delay>,
// TODO: ##other
// other: Vec<Other>,
pub errors: Vec<Error>,
@@ -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
}
}