Update xmpp dependency to 0.5

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
Maxime “pep” Buquet 2023-08-21 13:13:47 +02:00
parent 1aee1cd618
commit acf22a05c1
Signed by: pep
GPG key ID: DEDA74AEECA9D0F2
3 changed files with 9 additions and 11 deletions

View file

@ -17,5 +17,4 @@ pretty_env_logger = "0.5"
serde = { version = "1.0", features = [ "derive" ] } serde = { version = "1.0", features = [ "derive" ] }
serde_json = "1.0" serde_json = "1.0"
toml = "0.7" toml = "0.7"
xmpp = "0.4" xmpp = "0.5"
xmpp-parsers = "0.19"

View file

@ -16,8 +16,8 @@
use crate::webhook::{format_webhook, WebHook}; use crate::webhook::{format_webhook, WebHook};
use log::debug; use log::debug;
use xmpp::{Agent, ClientBuilder, ClientFeature, ClientType, Event}; use xmpp::parsers::message::MessageType;
use xmpp_parsers::{message::MessageType, BareJid, Jid}; use xmpp::{Agent, BareJid, ClientBuilder, ClientFeature, ClientType, Event, Jid};
pub struct XmppClient { pub struct XmppClient {
is_online: bool, is_online: bool,
@ -27,14 +27,13 @@ pub struct XmppClient {
} }
impl XmppClient { impl XmppClient {
pub fn new(jid: &str, password: &str, rooms: Vec<BareJid>, nickname: String) -> XmppClient { pub fn new(jid: BareJid, password: &str, rooms: Vec<BareJid>, nickname: String) -> XmppClient {
let agent = ClientBuilder::new(jid, password) let agent = ClientBuilder::new(jid, password)
.set_client(ClientType::Bot, "xmpp-rs") .set_client(ClientType::Bot, "xmpp-rs")
.set_website("https://gitlab.com/xmpp-rs/xmpp-rs") .set_website("https://gitlab.com/xmpp-rs/xmpp-rs")
.set_default_nick("bot") .set_default_nick("bot")
.enable_feature(ClientFeature::JoinRooms) .enable_feature(ClientFeature::JoinRooms)
.build() .build();
.unwrap();
XmppClient { XmppClient {
is_online: false, is_online: false,

View file

@ -16,15 +16,15 @@
#![feature(let_chains)] #![feature(let_chains)]
#![feature(never_type)] #![feature(never_type)]
mod bot;
mod error; mod error;
mod web; mod web;
mod webhook; mod webhook;
mod xmpp;
use crate::bot::XmppClient;
use crate::error::Error; use crate::error::Error;
use crate::web::webhooks; use crate::web::webhooks;
use crate::webhook::WebHook; use crate::webhook::WebHook;
use crate::xmpp::XmppClient;
use std::convert::Infallible; use std::convert::Infallible;
use std::fs::File; use std::fs::File;
@ -41,7 +41,7 @@ use hyper::{
use log::debug; use log::debug;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use tokio::sync::mpsc; use tokio::sync::mpsc;
use xmpp_parsers::BareJid; use xmpp::BareJid;
#[derive(Debug, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]
struct Config { struct Config {
@ -155,7 +155,7 @@ async fn main() -> Result<!, Error> {
} }
let mut client = XmppClient::new( let mut client = XmppClient::new(
&String::from(config.jid), config.jid,
config.password.as_str(), config.password.as_str(),
config.rooms, config.rooms,
config.nickname, config.nickname,