xmpp: update to edition 2024
Signed-off-by: pep <pep@bouah.net>
This commit is contained in:
parent
4a054ae802
commit
e503f016a3
19 changed files with 40 additions and 29 deletions
|
|
@ -11,7 +11,7 @@ repository = "https://gitlab.com/xmpp-rs/xmpp-rs"
|
|||
keywords = ["xmpp", "jabber", "chat", "messaging", "bot"]
|
||||
categories = ["network-programming"]
|
||||
license = "MPL-2.0"
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
chrono = "0.4"
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ XXXX-YY-ZZ [ RELEASER <admin@localhost> ]
|
|||
is meant to stay behind a feature. Also allows directly receiving
|
||||
stanzas.
|
||||
- Added documentation on `Event` enum.
|
||||
- Update to edition 2024
|
||||
* Fixes:
|
||||
- Use tokio::sync::RwLock not std::sync::RwLock (!432)
|
||||
- The default caps node has been shortened to https://xmpp.rs since we
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@
|
|||
#[cfg(feature = "rustls-any-backend")]
|
||||
use xmpp::tokio_xmpp::rustls;
|
||||
use xmpp::{
|
||||
Agent, ClientBuilder, ClientFeature, ClientType, Event, RoomNick,
|
||||
jid::BareJid,
|
||||
muc::room::{JoinRoomSettings, RoomMessageSettings},
|
||||
Agent, ClientBuilder, ClientFeature, ClientType, Event, RoomNick,
|
||||
};
|
||||
|
||||
use tokio::signal::ctrl_c;
|
||||
|
|
@ -21,7 +21,9 @@ use std::str::FromStr;
|
|||
feature = "rustls-any-backend",
|
||||
not(any(feature = "aws_lc_rs", feature = "ring"))
|
||||
))]
|
||||
compile_error!("using rustls (e.g. via the ktls feature) needs an enabled rustls backend feature (either aws_lc_rs or ring).");
|
||||
compile_error!(
|
||||
"using rustls (e.g. via the ktls feature) needs an enabled rustls backend feature (either aws_lc_rs or ring)."
|
||||
);
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Option<()>> {
|
||||
|
|
|
|||
|
|
@ -12,15 +12,15 @@ use tokio::io;
|
|||
use tokio::sync::RwLock;
|
||||
|
||||
use crate::{
|
||||
event_loop,
|
||||
Error, Event, RoomNick, event_loop,
|
||||
jid::{BareJid, Jid},
|
||||
message, muc,
|
||||
parsers::disco::DiscoInfoResult,
|
||||
upload, Error, Event, RoomNick,
|
||||
upload,
|
||||
};
|
||||
use tokio_xmpp::Client as TokioXmppClient;
|
||||
#[cfg(feature = "escape-hatch")]
|
||||
use tokio_xmpp::{stanzastream::StanzaToken, Stanza};
|
||||
use tokio_xmpp::{Stanza, stanzastream::StanzaToken};
|
||||
|
||||
pub struct Agent {
|
||||
pub(crate) client: TokioXmppClient,
|
||||
|
|
|
|||
|
|
@ -9,13 +9,13 @@ use crate::tokio_xmpp::connect::{DnsConfig, StartTlsServerConnector};
|
|||
use core::str::FromStr;
|
||||
|
||||
use crate::{
|
||||
Agent, ClientFeature, RoomNick,
|
||||
jid::{BareJid, Jid, ResourceRef},
|
||||
parsers::{
|
||||
disco::{DiscoInfoResult, Feature, Identity},
|
||||
ns,
|
||||
},
|
||||
tokio_xmpp::{connect::ServerConnector, xmlstream::Timeouts, Client as TokioXmppClient},
|
||||
Agent, ClientFeature, RoomNick,
|
||||
tokio_xmpp::{Client as TokioXmppClient, connect::ServerConnector, xmlstream::Timeouts},
|
||||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
|
|||
|
|
@ -49,10 +49,10 @@ pub fn message_time_info(message: &Message) -> StanzaTimeInfo {
|
|||
match Delay::try_from(payload.clone()) {
|
||||
Ok(delay) => delays.push(delay),
|
||||
Err(e) => {
|
||||
error!("Wrong <delay> format in payload from {}:{}\n{:?}\nUsing received time only.",
|
||||
message.from.as_ref().unwrap().to_owned(),
|
||||
e,
|
||||
payload);
|
||||
error!(
|
||||
"Wrong <delay> format in payload from {}:{e}\n{payload:?}\nUsing received time only.",
|
||||
message.from.as_ref().unwrap().to_owned()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use tokio_xmpp::parsers::roster::Item as RosterItem;
|
|||
use tokio_xmpp::parsers::{iq::Iq, message::Message, presence::Presence};
|
||||
|
||||
use crate::parsers::confirm::Confirm;
|
||||
use crate::{delay::StanzaTimeInfo, Error, MessageId, RoomNick};
|
||||
use crate::{Error, MessageId, RoomNick, delay::StanzaTimeInfo};
|
||||
|
||||
/// An Event notifying the client something has happened that may require attention.
|
||||
///
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@
|
|||
|
||||
use futures::StreamExt;
|
||||
use tokio_xmpp::{
|
||||
parsers::{disco::DiscoInfoQuery, iq::Iq, roster::Roster},
|
||||
Event as TokioXmppEvent, Stanza,
|
||||
parsers::{disco::DiscoInfoQuery, iq::Iq, roster::Roster},
|
||||
};
|
||||
|
||||
use crate::{iq, message, presence, Agent, Event};
|
||||
use crate::{Agent, Event, iq, message, presence};
|
||||
|
||||
/// Wait for new events, or Error::Disconnected when stream is closed and will not reconnect.
|
||||
pub async fn wait_for_events(agent: &mut Agent) -> Vec<Event> {
|
||||
|
|
|
|||
|
|
@ -5,12 +5,12 @@
|
|||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use crate::{
|
||||
disco,
|
||||
Agent, Event, RoomNick, disco,
|
||||
jid::Jid,
|
||||
minidom::Element,
|
||||
muc::room::JoinRoomSettings,
|
||||
parsers::{disco::DiscoInfoResult, ns, private::Query as PrivateXMLQuery, roster::Roster},
|
||||
pubsub, upload, Agent, Event, RoomNick,
|
||||
pubsub, upload,
|
||||
};
|
||||
|
||||
pub async fn handle_iq_result(
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use tokio_xmpp::{
|
|||
parsers::{confirm::Confirm, message::Message, message_correct::Replace, muc::user::MucUser},
|
||||
};
|
||||
|
||||
use crate::{delay::StanzaTimeInfo, Agent, Event, RoomNick};
|
||||
use crate::{Agent, Event, RoomNick, delay::StanzaTimeInfo};
|
||||
|
||||
pub async fn handle_message_chat(
|
||||
agent: &mut Agent,
|
||||
|
|
@ -43,7 +43,9 @@ pub async fn handle_message_chat(
|
|||
|
||||
if is_muc_pm {
|
||||
if from.resource().is_none() {
|
||||
warn!("Received malformed MessageType::Chat in muc#user namespace from a bare JID:\n{:#?}", message);
|
||||
warn!(
|
||||
"Received malformed MessageType::Chat in muc#user namespace from a bare JID:\n{message:#?}"
|
||||
);
|
||||
} else {
|
||||
let full_from = from.clone().try_into_full().unwrap();
|
||||
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@
|
|||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use crate::{
|
||||
Agent, Event, RoomNick,
|
||||
delay::StanzaTimeInfo,
|
||||
jid::Jid,
|
||||
parsers::{message::Message, message_correct::Replace},
|
||||
Agent, Event, RoomNick,
|
||||
};
|
||||
|
||||
pub async fn handle_message_group_chat(
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use tokio_xmpp::parsers::{
|
|||
ns,
|
||||
};
|
||||
|
||||
use crate::{delay::message_time_info, pubsub, Agent, Event};
|
||||
use crate::{Agent, Event, delay::message_time_info, pubsub};
|
||||
|
||||
pub mod chat;
|
||||
pub mod group_chat;
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@
|
|||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use crate::{
|
||||
Agent, RoomNick,
|
||||
jid::{BareJid, Jid},
|
||||
message::send::RawMessageSettings,
|
||||
parsers::{message::MessageType, muc::user::MucUser},
|
||||
Agent, RoomNick,
|
||||
};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use crate::{
|
||||
Agent, RoomNick,
|
||||
jid::{BareJid, ResourceRef},
|
||||
message::send::RawMessageSettings,
|
||||
parsers::{
|
||||
|
|
@ -12,7 +13,6 @@ use crate::{
|
|||
muc::Muc,
|
||||
presence::{Presence, Type as PresenceType},
|
||||
},
|
||||
Agent, RoomNick,
|
||||
};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
|
|
|||
|
|
@ -38,7 +38,10 @@ pub async fn handle_presence(agent: &mut Agent, presence: Presence) -> Vec<Event
|
|||
agent.rooms_joined.insert(from.clone(), nick.clone());
|
||||
agent.rooms_joining.remove(&from);
|
||||
} else {
|
||||
warn!("Received self-presence from {} while the room was not marked as joining.", presence.from.unwrap());
|
||||
warn!(
|
||||
"Received self-presence from {} while the room was not marked as joining.",
|
||||
presence.from.unwrap()
|
||||
);
|
||||
}
|
||||
events.push(Event::RoomJoined(from.clone()));
|
||||
}
|
||||
|
|
@ -48,7 +51,10 @@ pub async fn handle_presence(agent: &mut Agent, presence: Presence) -> Vec<Event
|
|||
agent.rooms_joined.remove(&from);
|
||||
agent.rooms_leaving.remove(&from);
|
||||
} else {
|
||||
warn!("Received self-presence unavailable from {} while the room was not marked as leaving.", presence.from.unwrap());
|
||||
warn!(
|
||||
"Received self-presence unavailable from {} while the room was not marked as leaving.",
|
||||
presence.from.unwrap()
|
||||
);
|
||||
}
|
||||
events.push(Event::RoomLeft(from.clone()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use tokio_xmpp::parsers::{
|
||||
caps::{compute_disco, hash_caps, Caps},
|
||||
caps::{Caps, compute_disco, hash_caps},
|
||||
disco::DiscoInfoResult,
|
||||
hashes::Algo,
|
||||
presence::{Presence, Type as PresenceType},
|
||||
|
|
|
|||
|
|
@ -14,9 +14,9 @@ use tokio_xmpp::parsers::{
|
|||
jid::Jid,
|
||||
ns,
|
||||
pubsub::{
|
||||
NodeName,
|
||||
event::Item,
|
||||
pubsub::{Items, PubSub},
|
||||
NodeName,
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use crate::{
|
||||
Agent, Event, RoomNick,
|
||||
jid::{BareJid, Jid},
|
||||
minidom::Element,
|
||||
muc::room::{JoinRoomSettings, LeaveRoomSettings},
|
||||
|
|
@ -12,7 +13,6 @@ use crate::{
|
|||
bookmarks2, ns,
|
||||
pubsub::{self, pubsub::PubSub},
|
||||
},
|
||||
Agent, Event, RoomNick,
|
||||
};
|
||||
|
||||
use std::str::FromStr;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use reqwest::{
|
||||
header::HeaderMap as ReqwestHeaderMap, Body as ReqwestBody, Client as ReqwestClient,
|
||||
Body as ReqwestBody, Client as ReqwestClient, header::HeaderMap as ReqwestHeaderMap,
|
||||
};
|
||||
use std::path::PathBuf;
|
||||
use tokio::fs::File;
|
||||
|
|
|
|||
Loading…
Reference in a new issue