From eb0b7ff02021832966bcb9af3abbb70c1c6e07c6 Mon Sep 17 00:00:00 2001 From: pep Date: Sat, 15 Nov 2025 14:13:38 +0100 Subject: [PATCH] Don't follow bookmarks autojoin config If this flag is enabled, the library expects bookmarks to be added to the account itself, and when there's no bookmark for a room, the corresponding room is automatically left. This doesn't work in the case where many instances of the bot are on the same account. It may work in the future if support for various sets of rooms/hooks are added, but for the moment it seemed easier (and maybe also more useful for other users of the xmpp-rs lib) to implement this. Signed-off-by: pep --- Cargo.toml | 2 +- Changelog | 7 +++++++ src/bot.rs | 7 ++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 456edba..e5a0811 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.9" -xmpp = { git = "https://gitlab.com/xmpp-rs/xmpp-rs", rev = "239a0191", default-features = false, features = [ "serde", "starttls", "rustls-native-certs", "aws_lc_rs" ] } +xmpp = { git = "https://gitlab.com/xmpp-rs/xmpp-rs", branch = "xmpp-config", default-features = false, features = [ "serde", "starttls", "rustls-native-certs", "aws_lc_rs" ] } hmac = "0.12" sha2 = "0.10" hex = "0.4" diff --git a/Changelog b/Changelog index b488965..5631b24 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,10 @@ +Version NEXT: +0000-00-00 RELEASER + * Changes: + - Prevent xmpp-rs dep from using `autojoin` flag for bookmarks which was + preventing from reusing the same account for multiple instances of the + bot. + Version 0.2.0: 2023-08-23 Maxime “pep” Buquet * Changes: diff --git a/src/bot.rs b/src/bot.rs index 968979e..26d6ed2 100644 --- a/src/bot.rs +++ b/src/bot.rs @@ -22,7 +22,7 @@ use xmpp::jid::{BareJid, Jid, ResourcePart}; use xmpp::parsers::message::MessageType; use xmpp::{ message::send::RawMessageSettings, muc::room::JoinRoomSettings, Agent, ClientBuilder, - ClientFeature, ClientType, Event, RoomNick, + ClientFeature, ClientType, Event, RoomNick, Config as AgentConfig, }; pub struct XmppClient { @@ -39,7 +39,12 @@ impl XmppClient { rooms: Vec, nickname: ResourcePart, ) -> XmppClient { + let config = AgentConfig { + bookmarks_autojoin: false, + ..AgentConfig::default() + }; let agent = ClientBuilder::new(jid, password) + .set_config(config) .set_client(ClientType::Bot, "xmpp-rs") .set_website("https://gitlab.com/xmpp-rs/xmpp-rs") .set_default_nick(&nickname)