From 91f1994af940085d5d475a97820900ebbf0eb553 Mon Sep 17 00:00:00 2001 From: cel 🌸 Date: Thu, 3 Apr 2025 03:41:38 +0100 Subject: feat: better message handling, pep publish, xep_0172: nick --- stanza/src/client/presence.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'stanza/src/client/presence.rs') diff --git a/stanza/src/client/presence.rs b/stanza/src/client/presence.rs index 8fb96be..bffb0d0 100644 --- a/stanza/src/client/presence.rs +++ b/stanza/src/client/presence.rs @@ -8,12 +8,14 @@ use peanuts::{ #[cfg(feature = "xep_0131")] use crate::xep_0131::Headers; +#[cfg(feature = "xep_0172")] +use crate::xep_0172::Nick; #[cfg(feature = "xep_0203")] use crate::xep_0203::Delay; use super::{error::Error, XMLNS}; -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] pub struct Presence { pub from: Option, pub id: Option, @@ -28,8 +30,9 @@ pub struct Presence { pub delay: Option, #[cfg(feature = "xep_0131")] pub headers: Option, - // TODO: ##other - // other: Vec, + #[cfg(feature = "xep_0172")] + pub nick: Option, + // ##other pub errors: Vec, } @@ -55,6 +58,9 @@ impl FromElement for Presence { #[cfg(feature = "xep_0131")] let headers = element.child_opt()?; + #[cfg(feature = "xep_0172")] + let nick = element.child_opt()?; + Ok(Presence { from, id, @@ -69,6 +75,8 @@ impl FromElement for Presence { delay, #[cfg(feature = "xep_0131")] headers, + #[cfg(feature = "xep_0172")] + nick, }) } } @@ -92,6 +100,9 @@ impl IntoElement for Presence { #[cfg(feature = "xep_0131")] let builder = builder.push_child_opt(self.headers.clone()); + #[cfg(feature = "xep_0172")] + let builder = builder.push_child_opt(self.nick.clone()); + builder } } -- cgit