aboutsummaryrefslogtreecommitdiffstats
path: root/filamento/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--filamento/src/lib.rs21
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)))