aboutsummaryrefslogtreecommitdiffstats
path: root/lampada
diff options
context:
space:
mode:
authorLibravatar cel 🌸 <cel@bunny.garden>2025-03-27 14:26:27 +0000
committerLibravatar cel 🌸 <cel@bunny.garden>2025-03-27 14:26:27 +0000
commite703284539384b461d204c73e7e14daead3f06d9 (patch)
tree3a49a5ed8b41e78a45dce91ad7723f4d6ebab26d /lampada
parent8c239e5c7a49cff350104b09cbb74d862c2ec420 (diff)
downloadluz-e703284539384b461d204c73e7e14daead3f06d9.tar.gz
luz-e703284539384b461d204c73e7e14daead3f06d9.tar.bz2
luz-e703284539384b461d204c73e7e14daead3f06d9.zip
feat: disco info from server
Diffstat (limited to 'lampada')
-rw-r--r--lampada/src/connection/mod.rs2
-rw-r--r--lampada/src/error.rs2
-rw-r--r--lampada/src/lib.rs20
3 files changed, 24 insertions, 0 deletions
diff --git a/lampada/src/connection/mod.rs b/lampada/src/connection/mod.rs
index ffaa7a7..2d570ae 100644
--- a/lampada/src/connection/mod.rs
+++ b/lampada/src/connection/mod.rs
@@ -298,6 +298,7 @@ impl SupervisorHandle {
streams: BoundJabberStream<Tls>,
on_crash: oneshot::Sender<()>,
jid: JID,
+ server: JID,
password: Arc<String>,
logic: Lgc,
) -> (WriteHandle, Self) {
@@ -313,6 +314,7 @@ impl SupervisorHandle {
let connected = Connected {
jid,
write_handle: write_handle.clone(),
+ server,
};
let supervisor_sender = SupervisorSender {
diff --git a/lampada/src/error.rs b/lampada/src/error.rs
index cdfb4db..384d1ee 100644
--- a/lampada/src/error.rs
+++ b/lampada/src/error.rs
@@ -20,6 +20,8 @@ pub enum ConnectionError {
// TODO: Display for Content
#[error("disconnected")]
Disconnected,
+ #[error("invalid server jid: {0}")]
+ InvalidServerJID(#[from] jid::ParseError),
}
#[derive(Debug, Error, Clone)]
diff --git a/lampada/src/lib.rs b/lampada/src/lib.rs
index a01ba06..7346c42 100644
--- a/lampada/src/lib.rs
+++ b/lampada/src/lib.rs
@@ -34,6 +34,8 @@ pub struct Connected {
// full jid will stay stable across reconnections
jid: JID,
write_handle: WriteHandle,
+ // the server jid
+ server: JID,
}
impl Connected {
@@ -44,6 +46,10 @@ impl Connected {
pub fn write_handle(&self) -> &WriteHandle {
&self.write_handle
}
+
+ pub fn server(&self) -> &JID {
+ &self.server
+ }
}
/// everything that a particular xmpp client must implement
@@ -166,6 +172,18 @@ impl<Lgc: Logic + Clone + Send + 'static> CoreClient<Lgc> {
let streams_result =
luz::connect_and_login(&mut jid, &*self.password, &mut domain)
.await;
+ let server: JID = match domain.parse() {
+ Ok(j) => j,
+ Err(e) => {
+ self.logic
+ .clone()
+ .handle_connection_error(ConnectionError::InvalidServerJID(
+ e,
+ ))
+ .await;
+ continue;
+ }
+ };
match streams_result {
Ok(s) => {
debug!("ok stream result");
@@ -174,6 +192,7 @@ impl<Lgc: Logic + Clone + Send + 'static> CoreClient<Lgc> {
s,
shutdown_send,
jid.clone(),
+ server.clone(),
self.password.clone(),
self.logic.clone(),
);
@@ -184,6 +203,7 @@ impl<Lgc: Logic + Clone + Send + 'static> CoreClient<Lgc> {
let connected = Connected {
jid,
write_handle: writer,
+ server,
};
self.logic.clone().handle_connect(connected.clone()).await;