diff options
| author | 2025-04-11 00:49:36 +0100 | |
|---|---|---|
| committer | 2025-04-11 00:49:36 +0100 | |
| commit | aab4cd47b1d2da5539c50675be4c7a36898189ef (patch) | |
| tree | 3338bab6b08a076c8b39e8c3cb06a22f40a66e04 /filamento/src/logic | |
| parent | af7a0f5022dfd0e04c821f0d4fc8314b3578417c (diff) | |
| download | luz-aab4cd47b1d2da5539c50675be4c7a36898189ef.tar.gz luz-aab4cd47b1d2da5539c50675be4c7a36898189ef.tar.bz2 luz-aab4cd47b1d2da5539c50675be4c7a36898189ef.zip | |
feat(filamento): `get_roster_with_users()`
Diffstat (limited to '')
| -rw-r--r-- | filamento/src/logic/offline.rs | 11 | ||||
| -rw-r--r-- | filamento/src/logic/online.rs | 18 | 
2 files changed, 28 insertions, 1 deletions
| diff --git a/filamento/src/logic/offline.rs b/filamento/src/logic/offline.rs index 566972c..82b3298 100644 --- a/filamento/src/logic/offline.rs +++ b/filamento/src/logic/offline.rs @@ -14,6 +14,7 @@ use crate::{      files::FileStore,      presence::Online,      roster::Contact, +    user::User,  };  use super::{ @@ -47,6 +48,12 @@ pub async fn handle_get_roster<Fs: FileStore + Clone>(      Ok(logic.db().read_cached_roster().await?)  } +pub async fn handle_get_roster_with_users<Fs: FileStore + Clone>( +    logic: &ClientLogic<Fs>, +) -> Result<Vec<(Contact, User)>, RosterError> { +    Ok(logic.db().read_cached_roster_with_users().await?) +} +  pub async fn handle_offline_result<Fs: FileStore + Clone>(      logic: &ClientLogic<Fs>,      command: Command<Fs>, @@ -56,6 +63,10 @@ pub async fn handle_offline_result<Fs: FileStore + Clone>(              let roster = handle_get_roster(logic).await;              sender.send(roster);          } +        Command::GetRosterWithUsers(sender) => { +            let roster = handle_get_roster_with_users(logic).await; +            sender.send(roster); +        }          Command::GetChats(sender) => {              let chats = handle_get_chats(logic).await;              sender.send(chats); diff --git a/filamento/src/logic/online.rs b/filamento/src/logic/online.rs index d9441d7..d5242e0 100644 --- a/filamento/src/logic/online.rs +++ b/filamento/src/logic/online.rs @@ -18,7 +18,7 @@ use uuid::Uuid;  use crate::{      avatar, chat::{Body, Chat, Delivery, Message}, disco::{Info, Items}, error::{          AvatarPublishError, DatabaseError, DiscoError, Error, IqRequestError, MessageSendError, NickError, PEPError, RosterError, StatusError, SubscribeError -    }, files::FileStore, pep, presence::{Online, Presence, PresenceType}, roster::{Contact, ContactUpdate}, Command, UpdateMessage +    }, files::FileStore, pep, presence::{Online, Presence, PresenceType}, roster::{Contact, ContactUpdate}, user::User, Command, UpdateMessage  };  use super::{ @@ -97,6 +97,18 @@ pub async fn handle_get_roster<Fs: FileStore + Clone>(      }  } +pub async fn handle_get_roster_with_users<Fs: FileStore + Clone>( +    logic: &ClientLogic<Fs>, +) -> Result<Vec<(Contact, User)>, RosterError> { +    let roster = logic.client.get_roster().await?; +    let mut users = Vec::new(); +    for contact in &roster { +        let user = logic.db().read_user(contact.user_jid.clone()).await?; +        users.push(user); +    } +    Ok(roster.into_iter().zip(users).collect()) +} +  pub async fn handle_add_contact<Fs: FileStore + Clone>(      logic: &ClientLogic<Fs>,      connection: Connected, @@ -1006,6 +1018,10 @@ pub async fn handle_online_result<Fs: FileStore + Clone>(              let roster = handle_get_roster(logic, connection).await;              let _ = result_sender.send(roster);          } +        Command::GetRosterWithUsers(result_sender) => { +            let roster = handle_get_roster_with_users(logic).await; +            let _ = result_sender.send(roster); +        }          Command::GetChats(sender) => {              let chats = handle_get_chats(logic).await;              let _ = sender.send(chats); | 
