diff --git a/Cargo.toml b/Cargo.toml index b0d3d1b..caf981f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,12 +16,11 @@ http-body-util = "0.1" bytes = "1.6" log = "0.4" tokio = { version = "1", default-features = false, features = [ "rt", "net", "sync", "fs" ] } -tokio-xmpp = { version = "4.0.0", default-features = false } pretty_env_logger = "0.5" serde = { version = "1.0", features = [ "derive" ] } serde_json = "1.0" toml = "0.8" -xmpp = { version = "0.6", default-features = false, features = [ "serde", "starttls-native"] } +xmpp = { git = "https://gitlab.com/xmpp-rs/xmpp-rs", rev = "274baaef9afb", default-features = false, features = [ "serde", "starttls-native"] } hmac = "0.12" sha2 = "0.10" hex = "0.4" diff --git a/src/bot.rs b/src/bot.rs index 6dfb09c..25dea32 100644 --- a/src/bot.rs +++ b/src/bot.rs @@ -16,14 +16,14 @@ use crate::hook::{format_hook, GitlabHook}; use log::debug; -use tokio_xmpp::starttls::ServerConfig; use xmpp::jid::{BareJid, Jid}; use xmpp::parsers::message::MessageType; +use xmpp::tokio_xmpp::connect::StartTlsServerConnector; use xmpp::{Agent, ClientBuilder, ClientFeature, ClientType, Event}; pub struct XmppClient { is_online: bool, - agent: Agent, + agent: Agent, rooms: Vec, nickname: String, } @@ -46,33 +46,31 @@ impl XmppClient { } pub async fn next(&mut self) { - if let Some(events) = self.agent.wait_for_events().await { - for event in events { - match event { - Event::Online => { - self.is_online = true; - debug!("XMPP Online"); + for event in self.agent.wait_for_events().await { + match event { + Event::Online => { + self.is_online = true; + debug!("XMPP Online"); - for room in &self.rooms { - self.agent - .join_room( - room.clone(), - Some(self.nickname.clone()), - None, - "en", - "Hi there!", - ) - .await - } - } - Event::Disconnected(e) => { - self.is_online = false; - debug!("XMPP Disconnected: {e}"); - } - _ => { - debug!("XMPP Event not supported") + for room in &self.rooms { + self.agent + .join_room( + room.clone(), + Some(self.nickname.clone()), + None, + "en", + "Hi there!", + ) + .await } } + Event::Disconnected(e) => { + self.is_online = false; + debug!("XMPP Disconnected: {e}"); + } + _ => { + debug!("XMPP Event not supported") + } } } } @@ -84,7 +82,7 @@ impl XmppClient { for room in &self.rooms { self.agent .send_message( - Jid::Bare(room.clone()), + Jid::from(room.clone()), MessageType::Groupchat, "en", &display,