diff options
Diffstat (limited to 'stanza/src/client/message.rs')
-rw-r--r-- | stanza/src/client/message.rs | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/stanza/src/client/message.rs b/stanza/src/client/message.rs index 893e7cf..192390b 100644 --- a/stanza/src/client/message.rs +++ b/stanza/src/client/message.rs @@ -6,6 +6,9 @@ use peanuts::{ DeserializeError, Element, XML_NS, }; +#[cfg(feature = "xep_0203")] +use crate::xep_0203::Delay; + use super::XMLNS; #[derive(Debug, Clone)] @@ -20,6 +23,8 @@ pub struct Message { pub subject: Option<Subject>, pub body: Option<Body>, pub thread: Option<Thread>, + #[cfg(feature = "xep_0203")] + pub delay: Option<Delay>, } impl FromElement for Message { @@ -37,6 +42,9 @@ impl FromElement for Message { let body = element.child_opt()?; let thread = element.child_opt()?; + #[cfg(feature = "xep_0203")] + let delay = element.child_opt()?; + Ok(Message { from, id, @@ -46,13 +54,15 @@ impl FromElement for Message { subject, body, thread, + #[cfg(feature = "xep_0203")] + delay, }) } } impl IntoElement for Message { fn builder(&self) -> peanuts::element::ElementBuilder { - Element::builder("message", Some(XMLNS)) + let builder = Element::builder("message", Some(XMLNS)) .push_attribute_opt("from", self.from.clone()) .push_attribute_opt("id", self.id.clone()) .push_attribute_opt("to", self.to.clone()) @@ -66,7 +76,12 @@ impl IntoElement for Message { .push_attribute_opt_namespaced(XML_NS, "lang", self.lang.clone()) .push_child_opt(self.subject.clone()) .push_child_opt(self.body.clone()) - .push_child_opt(self.thread.clone()) + .push_child_opt(self.thread.clone()); + + #[cfg(feature = "xep_0203")] + let builder = builder.push_child_opt(self.delay.clone()); + + builder } } |