diff options
author | 2025-04-03 13:50:51 +0100 | |
---|---|---|
committer | 2025-04-03 13:50:51 +0100 | |
commit | 20969bd8b9789c08303265ec263e02b5225348e6 (patch) | |
tree | 0f45ec5e42f350b4554a1e269973451b8efeca42 | |
parent | f48642bbd5a210b68e60715b59b1f24cf2d77fea (diff) | |
download | luz-main.tar.gz luz-main.tar.bz2 luz-main.zip |
-rw-r--r-- | README.md | 14 | ||||
-rw-r--r-- | filamento/src/logic/process_stanza.rs | 49 | ||||
-rw-r--r-- | stanza/src/client/message.rs | 12 | ||||
-rw-r--r-- | stanza/src/xep_0060/event.rs | 10 |
4 files changed, 74 insertions, 11 deletions
@@ -24,14 +24,12 @@ - [x] xep-0203: delayed delivery - [x] xep-0030: service discovery - [x] xep-0115: entity capabilities -- [ ] xep-0163: pep +- [x] xep-0163: pep - [ ] xep-0245: /me - [ ] xep-0084: user avatar -- [ ] xep-0172: user nickname +- [x] xep-0172: user nickname - [ ] xep-0280: message carbons - [ ] xep-0191: blocking -- [ ] xep-0222: public data via pubsub -- [ ] xep-0223: private data via pubsub - [ ] xep-0313: mam - [ ] xep-0198: stream management - [ ] xep-0085: chat state notifications @@ -45,9 +43,7 @@ - [ ] xep-0490: message displayed synchronization - [ ] xep-0333: displayed markers - [ ] xep-0184: message delivery receipts -- [ ] xep-0060: pubsub - [ ] xep-0100: gateway interation -- [ ] xep-0402: pep native bookmarks calls: - [ ] xep-0167: jingle rtp sessions @@ -88,6 +84,7 @@ will prioritise new spec instead of: - [ ] xep-0045: muc - [ ] xep-0249: direct muc invitations - [ ] xep-0410: muc self-ping + - [ ] xep-0402: pep native bookmarks - [ ] vcard legacy - [ ] xep-0398: user avatar compat - [ ] xep-0153: vcard avatars @@ -96,6 +93,11 @@ will prioritise new spec instead of: - [ ] xep-0048: legacy bookmarks - [ ] xep-0049: private xml storage +pubsub: +- [ ] xep-0060: pubsub +- [ ] xep-0222: public data via pubsub +- [ ] xep-0223: private data via pubsub + later (nice to have): - [ ] xep-0077: in-band registration - [ ] xep-0157: contact addresses diff --git a/filamento/src/logic/process_stanza.rs b/filamento/src/logic/process_stanza.rs index 182fb43..11d7588 100644 --- a/filamento/src/logic/process_stanza.rs +++ b/filamento/src/logic/process_stanza.rs @@ -9,6 +9,7 @@ use stanza::{ }, stanza_error::Error as StanzaError, xep_0030::{self, info}, + xep_0060::event::{Content, Event, ItemsType}, }; use tracing::{debug, error, info, warn}; use uuid::Uuid; @@ -107,6 +108,54 @@ pub async fn recv_message( .await; } + if let Some(event) = stanza_message.event { + match event { + Event::Items(items) => match items.node.as_str() { + "http://jabber.org/protocol/nick" => match items.items { + ItemsType::Item(items) => { + if let Some(item) = items.first() { + match &item.item { + Some(c) => match c { + Content::Nick(nick) => { + if let Err(e) = logic + .db() + .upsert_user_nick(from.as_bare(), nick.0.clone()) + .await + { + logic + .handle_error(Error::MessageRecv( + MessageRecvError::NickUpdate(e), + )) + .await; + } + + logic + .update_sender() + .send(UpdateMessage::NickChanged { + jid: from.as_bare(), + nick: nick.0.clone(), + }) + .await; + } + Content::Unknown(element) => {} + }, + None => {} + } + } + } + ItemsType::Retract(retracts) => {} + }, + _ => {} + }, + // Event::Collection(collection) => todo!(), + // Event::Configuration(configuration) => todo!(), + // Event::Delete(delete) => todo!(), + // Event::Purge(purge) => todo!(), + // Event::Subscription(subscription) => todo!(), + _ => {} + } + } + Ok(None) // TODO: can this be more efficient? } else { diff --git a/stanza/src/client/message.rs b/stanza/src/client/message.rs index d94b82e..78258ca 100644 --- a/stanza/src/client/message.rs +++ b/stanza/src/client/message.rs @@ -6,6 +6,8 @@ use peanuts::{ DeserializeError, Element, XML_NS, }; +#[cfg(feature = "xep_0060")] +use crate::xep_0060::event::Event; #[cfg(feature = "xep_0131")] use crate::xep_0131::Headers; #[cfg(feature = "xep_0172")] @@ -33,6 +35,8 @@ pub struct Message { pub headers: Option<Headers>, #[cfg(feature = "xep_0172")] pub nick: Option<Nick>, + #[cfg(feature = "xep_0060")] + pub event: Option<Event>, } impl FromElement for Message { @@ -59,6 +63,9 @@ impl FromElement for Message { #[cfg(feature = "xep_0172")] let nick = element.child_opt()?; + #[cfg(feature = "xep_0060")] + let event = element.child_opt()?; + Ok(Message { from, id, @@ -74,6 +81,8 @@ impl FromElement for Message { headers, #[cfg(feature = "xep_0172")] nick, + #[cfg(feature = "xep_0060")] + event, }) } } @@ -105,6 +114,9 @@ impl IntoElement for Message { #[cfg(feature = "xep_0172")] let builder = builder.push_child_opt(self.nick.clone()); + #[cfg(feature = "xep_0060")] + let builder = builder.push_child_opt(self.event.clone()); + builder } } diff --git a/stanza/src/xep_0060/event.rs b/stanza/src/xep_0060/event.rs index d2c150a..4ef5a6c 100644 --- a/stanza/src/xep_0060/event.rs +++ b/stanza/src/xep_0060/event.rs @@ -219,8 +219,8 @@ impl IntoElement for Delete { #[derive(Clone, Debug)] pub struct Items { - node: String, - items: ItemsType, + pub node: String, + pub items: ItemsType, } impl FromElement for Items { @@ -260,9 +260,9 @@ pub enum ItemsType { #[derive(Clone, Debug)] pub struct Item { - id: Option<String>, - publisher: Option<String>, - item: Option<Content>, + pub id: Option<String>, + pub publisher: Option<String>, + pub item: Option<Content>, } impl FromElement for Item { |