From ba5ad94525940e3e34983425961550c67afc49ae Mon Sep 17 00:00:00 2001 From: cel 🌸 Date: Fri, 28 Mar 2025 22:44:11 +0000 Subject: feat(filamento): disco info requests --- filamento/src/lib.rs | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'filamento/src/lib.rs') 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>), - /// disco info request - DiscoInfo(JID, oneshot::Sender), + /// disco info query + DiscoInfo( + Option, + oneshot::Sender>, + ), + // /// disco items query + // DiscoItems(JID, oneshot::Sender>), } #[derive(Debug, Clone)] @@ -473,6 +479,18 @@ impl Client { .map_err(|e| CommandError::Actor(Into::::into(e)))??; Ok(result) } + + pub async fn disco_info(&self, jid: Option) -> Result> { + let (send, recv) = oneshot::channel(); + self.send(CoreClientCommand::Command(Command::DiscoInfo(jid, send))) + .await + .map_err(|e| CommandError::Actor(Into::::into(e)))?; + let result = timeout(self.timeout, recv) + .await + .map_err(|e| CommandError::Actor(Into::::into(e)))? + .map_err(|e| CommandError::Actor(Into::::into(e)))??; + Ok(result) + } } impl From for CoreClientCommand { -- cgit