Update to xmpp main (274baaef9afb)

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
Maxime “pep” Buquet 2024-08-30 19:24:17 +02:00
parent 9bc8a77da6
commit 77c193bfb6
2 changed files with 26 additions and 29 deletions

View file

@ -16,12 +16,11 @@ http-body-util = "0.1"
bytes = "1.6" bytes = "1.6"
log = "0.4" log = "0.4"
tokio = { version = "1", default-features = false, features = [ "rt", "net", "sync", "fs" ] } 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" 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.8" 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" hmac = "0.12"
sha2 = "0.10" sha2 = "0.10"
hex = "0.4" hex = "0.4"

View file

@ -16,14 +16,14 @@
use crate::hook::{format_hook, GitlabHook}; use crate::hook::{format_hook, GitlabHook};
use log::debug; use log::debug;
use tokio_xmpp::starttls::ServerConfig;
use xmpp::jid::{BareJid, Jid}; use xmpp::jid::{BareJid, Jid};
use xmpp::parsers::message::MessageType; use xmpp::parsers::message::MessageType;
use xmpp::tokio_xmpp::connect::StartTlsServerConnector;
use xmpp::{Agent, ClientBuilder, ClientFeature, ClientType, Event}; use xmpp::{Agent, ClientBuilder, ClientFeature, ClientType, Event};
pub struct XmppClient { pub struct XmppClient {
is_online: bool, is_online: bool,
agent: Agent<ServerConfig>, agent: Agent<StartTlsServerConnector>,
rooms: Vec<BareJid>, rooms: Vec<BareJid>,
nickname: String, nickname: String,
} }
@ -46,8 +46,7 @@ impl XmppClient {
} }
pub async fn next(&mut self) { pub async fn next(&mut self) {
if let Some(events) = self.agent.wait_for_events().await { for event in self.agent.wait_for_events().await {
for event in events {
match event { match event {
Event::Online => { Event::Online => {
self.is_online = true; self.is_online = true;
@ -75,7 +74,6 @@ impl XmppClient {
} }
} }
} }
}
pub async fn hook(&mut self, wh: GitlabHook) { pub async fn hook(&mut self, wh: GitlabHook) {
debug!("Received Hook"); debug!("Received Hook");
@ -84,7 +82,7 @@ impl XmppClient {
for room in &self.rooms { for room in &self.rooms {
self.agent self.agent
.send_message( .send_message(
Jid::Bare(room.clone()), Jid::from(room.clone()),
MessageType::Groupchat, MessageType::Groupchat,
"en", "en",
&display, &display,