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"
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"

View file

@ -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<ServerConfig>,
agent: Agent<StartTlsServerConnector>,
rooms: Vec<BareJid>,
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,