diff options
Diffstat (limited to '')
-rw-r--r-- | filamento/src/lib.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/filamento/src/lib.rs b/filamento/src/lib.rs index 83d4991..97cc9cd 100644 --- a/filamento/src/lib.rs +++ b/filamento/src/lib.rs @@ -66,6 +66,12 @@ pub enum Command<Fs: FileStore> { /// get message history for chat (does appropriate mam things) // TODO: paging and filtering GetMessages(JID, oneshot::Sender<Result<Vec<Message>, DatabaseError>>), + /// get message history for chat (does appropriate mam things) + // TODO: paging and filtering + GetMessagesWithUsers( + JID, + oneshot::Sender<Result<Vec<(Message, User)>, DatabaseError>>, + ), /// delete a chat from your chat history, along with all the corresponding messages DeleteChat(JID, oneshot::Sender<Result<(), DatabaseError>>), /// delete a message from your chat history @@ -360,6 +366,23 @@ impl<Fs: FileStore> Client<Fs> { Ok(messages) } + pub async fn get_messages_with_users( + &self, + jid: JID, + ) -> Result<Vec<(Message, User)>, CommandError<DatabaseError>> { + let (send, recv) = oneshot::channel(); + self.send(CoreClientCommand::Command(Command::GetMessagesWithUsers( + jid, send, + ))) + .await + .map_err(|e| CommandError::Actor(Into::<ActorError>::into(e)))?; + let messages = timeout(self.timeout, recv) + .await + .map_err(|e| CommandError::Actor(Into::<ActorError>::into(e)))? + .map_err(|e| CommandError::Actor(Into::<ActorError>::into(e)))??; + Ok(messages) + } + pub async fn delete_chat(&self, jid: JID) -> Result<(), CommandError<DatabaseError>> { let (send, recv) = oneshot::channel(); self.send(CoreClientCommand::Command(Command::DeleteChat(jid, send))) |