diff options
Diffstat (limited to '')
| -rw-r--r-- | filamento/src/logic/process_stanza.rs | 49 | 
1 files changed, 49 insertions, 0 deletions
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 {  | 
