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 <pep@bouah.net>
This commit is contained in:
pep 2025-11-15 14:13:38 +01:00
commit eb0b7ff020
No known key found for this signature in database
GPG key ID: DEDA74AEECA9D0F2
3 changed files with 14 additions and 2 deletions

View file

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

View file

@ -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 <pep@bouah.net>
* Changes:

View file

@ -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<BareJid>,
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)