diff options
author | 2025-05-19 11:39:15 +0100 | |
---|---|---|
committer | 2025-05-19 11:39:15 +0100 | |
commit | 7b3ed73184f375004af6db62654af0e69e7d14d3 (patch) | |
tree | b8c11e848f475bb0c8f31641c13e032b5fac7714 /filamento/src/lib.rs | |
parent | 97ad4e3403bf0d9c3a4a030a377ec6fde31b166e (diff) | |
download | luz-7b3ed73184f375004af6db62654af0e69e7d14d3.tar.gz luz-7b3ed73184f375004af6db62654af0e69e7d14d3.tar.bz2 luz-7b3ed73184f375004af6db62654af0e69e7d14d3.zip |
feat(filamento): read_chat_and_user()
Diffstat (limited to '')
-rw-r--r-- | filamento/src/lib.rs | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/filamento/src/lib.rs b/filamento/src/lib.rs index 8b27441..068bfe8 100644 --- a/filamento/src/lib.rs +++ b/filamento/src/lib.rs @@ -69,6 +69,8 @@ pub enum Command<Fs: FileStore> { ), /// get a specific chat by jid GetChat(JID, oneshot::Sender<Result<Chat, DatabaseError>>), + /// get a specific chat and user by jid + GetChatAndUser(JID, oneshot::Sender<Result<(Chat, User), DatabaseError>>), /// get message history for chat (does appropriate mam things) GetMessage(Uuid, oneshot::Sender<Result<Message, DatabaseError>>), // TODO: paging and filtering @@ -269,8 +271,9 @@ impl<Fs: FileStore + Clone + Send + Sync + 'static> Client<Fs> { } impl<Fs: FileStore> Client<Fs> { - pub async fn connect(&self) -> Result<(), CommandError<ConnectionError>> { - let (send, recv) = oneshot::channel::<Result<(), ConnectionError>>(); + /// returns the resource + pub async fn connect(&self) -> Result<String, CommandError<ConnectionError>> { + let (send, recv) = oneshot::channel::<Result<String, ConnectionError>>(); self.send(CoreClientCommand::Connect(send)) .await .map_err(|e| CommandError::Actor(Into::<ActorError>::into(e)))?; @@ -278,7 +281,7 @@ impl<Fs: FileStore> Client<Fs> { .await .map_err(|e| CommandError::Actor(Into::<ActorError>::into(e)))? .map_err(|e| CommandError::Actor(Into::<ActorError>::into(e)))??; - Ok(()) + Ok(result) } pub async fn disconnect(&self, offline: Offline) -> Result<(), ActorError> { @@ -382,6 +385,18 @@ impl<Fs: FileStore> Client<Fs> { Ok(chat) } + pub async fn get_chat_and_user(&self, jid: JID) -> Result<(Chat, User), CommandError<DatabaseError>> { + let (send, recv) = oneshot::channel(); + self.send(CoreClientCommand::Command(Command::GetChatAndUser(jid, send))) + .await + .map_err(|e| CommandError::Actor(Into::<ActorError>::into(e)))?; + let result= timeout(self.timeout, recv) + .await + .map_err(|e| CommandError::Actor(Into::<ActorError>::into(e)))? + .map_err(|e| CommandError::Actor(Into::<ActorError>::into(e)))??; + Ok(result) + } + pub async fn get_message(&self, id: Uuid) -> Result<Message, CommandError<DatabaseError>> { let (send, recv) = oneshot::channel(); self.send(CoreClientCommand::Command(Command::GetMessage(id, send))) |