aboutsummaryrefslogtreecommitdiffstats
path: root/filamento/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'filamento/src/lib.rs')
-rw-r--r--filamento/src/lib.rs24
1 files changed, 21 insertions, 3 deletions
diff --git a/filamento/src/lib.rs b/filamento/src/lib.rs
index bc946ae..ed33e99 100644
--- a/filamento/src/lib.rs
+++ b/filamento/src/lib.rs
@@ -9,8 +9,9 @@ use std::{
use chat::{Body, Chat, Message};
use chrono::Utc;
use db::Db;
+use disco::Info;
use error::{
- ConnectionJobError, DatabaseError, Error, IqError, MessageRecvError, PresenceError,
+ ConnectionJobError, DatabaseError, DiscoError, Error, IqError, MessageRecvError, PresenceError,
RosterError, StatusError,
};
use futures::FutureExt;
@@ -98,8 +99,13 @@ pub enum Command {
/// send a message to a jid (any kind of jid that can receive a message, e.g. a user or a
/// chatroom). if disconnected, will be cached so when client connects, message will be sent.
SendMessage(JID, Body, oneshot::Sender<Result<(), WriteError>>),
- /// disco info request
- DiscoInfo(JID, oneshot::Sender<Result>),
+ /// disco info query
+ DiscoInfo(
+ Option<JID>,
+ oneshot::Sender<Result<disco::Info, DiscoError>>,
+ ),
+ // /// disco items query
+ // DiscoItems(JID, oneshot::Sender<Result<disco::Info, DiscoError>>),
}
#[derive(Debug, Clone)]
@@ -473,6 +479,18 @@ impl Client {
.map_err(|e| CommandError::Actor(Into::<ActorError>::into(e)))??;
Ok(result)
}
+
+ pub async fn disco_info(&self, jid: Option<JID>) -> Result<Info, CommandError<DiscoError>> {
+ let (send, recv) = oneshot::channel();
+ self.send(CoreClientCommand::Command(Command::DiscoInfo(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)
+ }
}
impl From<Command> for CoreClientCommand<Command> {