diff --git a/Cargo.toml b/Cargo.toml index 6562de1..6710cf1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ pretty_env_logger = "0.5" serde = { version = "1.0", features = [ "derive" ] } serde_json = "1.0" toml = "0.8" -xmpp = { git = "https://gitlab.com/xmpp-rs/xmpp-rs", rev = "5bc94dce95", default-features = false, features = [ "serde", "starttls-native"] } +xmpp = { git = "https://gitlab.com/xmpp-rs/xmpp-rs", rev = "ec72d71551", 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 d1a3c3f..4679a3a 100644 --- a/src/bot.rs +++ b/src/bot.rs @@ -33,8 +33,7 @@ pub struct XmppClient { } impl XmppClient { - pub fn new(jid: BareJid, password: &str, rooms: Vec, nickname: String) -> XmppClient { - let nickname: ResourcePart = ResourcePart::new(&nickname).unwrap().into(); + pub fn new(jid: BareJid, password: &str, rooms: Vec, nickname: ResourcePart) -> XmppClient { let agent = ClientBuilder::new(jid, password) .set_client(ClientType::Bot, "xmpp-rs") .set_website("https://gitlab.com/xmpp-rs/xmpp-rs") diff --git a/src/config.rs b/src/config.rs index 091389d..687a660 100644 --- a/src/config.rs +++ b/src/config.rs @@ -19,7 +19,7 @@ use std::net::{IpAddr, Ipv6Addr, SocketAddr}; use camino::{Utf8Path, Utf8PathBuf}; use log::debug; use serde::{Deserialize, Serialize}; -use xmpp::jid::BareJid; +use xmpp::jid::{BareJid, ResourcePart}; use crate::error::Error; @@ -37,7 +37,7 @@ pub struct Config { /// Nickname to use in rooms #[serde(default = "Config::default_nickname")] - pub nickname: String, + pub nickname: ResourcePart, /// Secret that matches the one provided to the Webhook service #[serde(rename = "secret")] @@ -49,8 +49,8 @@ pub struct Config { } impl Config { - pub fn default_nickname() -> String { - String::from("cusku") + pub fn default_nickname() -> ResourcePart { + ResourcePart::new("cusku").unwrap().into() } pub fn default_addr() -> SocketAddr {