From acf22a05c1f2dee1008db285ab597db5e1e5b8c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Mon, 21 Aug 2023 13:13:47 +0200 Subject: [PATCH] Update xmpp dependency to 0.5 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- Cargo.toml | 3 +-- src/{xmpp.rs => bot.rs} | 9 ++++----- src/main.rs | 8 ++++---- 3 files changed, 9 insertions(+), 11 deletions(-) rename src/{xmpp.rs => bot.rs} (89%) diff --git a/Cargo.toml b/Cargo.toml index 59205b8..d8cf38b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,5 +17,4 @@ pretty_env_logger = "0.5" serde = { version = "1.0", features = [ "derive" ] } serde_json = "1.0" toml = "0.7" -xmpp = "0.4" -xmpp-parsers = "0.19" +xmpp = "0.5" diff --git a/src/xmpp.rs b/src/bot.rs similarity index 89% rename from src/xmpp.rs rename to src/bot.rs index 7972c98..4630d2a 100644 --- a/src/xmpp.rs +++ b/src/bot.rs @@ -16,8 +16,8 @@ use crate::webhook::{format_webhook, WebHook}; use log::debug; -use xmpp::{Agent, ClientBuilder, ClientFeature, ClientType, Event}; -use xmpp_parsers::{message::MessageType, BareJid, Jid}; +use xmpp::parsers::message::MessageType; +use xmpp::{Agent, BareJid, ClientBuilder, ClientFeature, ClientType, Event, Jid}; pub struct XmppClient { is_online: bool, @@ -27,14 +27,13 @@ pub struct XmppClient { } impl XmppClient { - pub fn new(jid: &str, password: &str, rooms: Vec, nickname: String) -> XmppClient { + pub fn new(jid: BareJid, password: &str, rooms: Vec, nickname: String) -> XmppClient { let agent = ClientBuilder::new(jid, password) .set_client(ClientType::Bot, "xmpp-rs") .set_website("https://gitlab.com/xmpp-rs/xmpp-rs") .set_default_nick("bot") .enable_feature(ClientFeature::JoinRooms) - .build() - .unwrap(); + .build(); XmppClient { is_online: false, diff --git a/src/main.rs b/src/main.rs index b07e72e..964be89 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,15 +16,15 @@ #![feature(let_chains)] #![feature(never_type)] +mod bot; mod error; mod web; mod webhook; -mod xmpp; +use crate::bot::XmppClient; use crate::error::Error; use crate::web::webhooks; use crate::webhook::WebHook; -use crate::xmpp::XmppClient; use std::convert::Infallible; use std::fs::File; @@ -41,7 +41,7 @@ use hyper::{ use log::debug; use serde::{Deserialize, Serialize}; use tokio::sync::mpsc; -use xmpp_parsers::BareJid; +use xmpp::BareJid; #[derive(Debug, Serialize, Deserialize)] struct Config { @@ -155,7 +155,7 @@ async fn main() -> Result { } let mut client = XmppClient::new( - &String::from(config.jid), + config.jid, config.password.as_str(), config.rooms, config.nickname,