aboutsummaryrefslogtreecommitdiffstats
path: root/filamento
diff options
context:
space:
mode:
authorLibravatar cel 🌸 <cel@bunny.garden>2025-04-03 13:50:51 +0100
committerLibravatar cel 🌸 <cel@bunny.garden>2025-04-03 13:50:51 +0100
commit20969bd8b9789c08303265ec263e02b5225348e6 (patch)
tree0f45ec5e42f350b4554a1e269973451b8efeca42 /filamento
parentf48642bbd5a210b68e60715b59b1f24cf2d77fea (diff)
downloadluz-20969bd8b9789c08303265ec263e02b5225348e6.tar.gz
luz-20969bd8b9789c08303265ec263e02b5225348e6.tar.bz2
luz-20969bd8b9789c08303265ec263e02b5225348e6.zip
feat(filamento): xep-0172: user nick
Diffstat (limited to 'filamento')
-rw-r--r--filamento/src/logic/process_stanza.rs49
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 {