From ba6a7c47445c02ea89139677962d46b2c695a5d9 Mon Sep 17 00:00:00 2001 From: xmppftw Date: Tue, 6 Aug 2024 16:04:04 +0200 Subject: [PATCH] Use tokio::sync::RwLock instead of std --- xmpp/ChangeLog | 5 +++++ xmpp/src/agent.rs | 3 ++- xmpp/src/builder.rs | 3 ++- xmpp/src/muc/room.rs | 7 ++++++- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/xmpp/ChangeLog b/xmpp/ChangeLog index 44b073b2..3d284dcf 100644 --- a/xmpp/ChangeLog +++ b/xmpp/ChangeLog @@ -1,3 +1,8 @@ +Version NEXT +XXXX-YY-ZZ [ RELEASER ] + * Fixes: + - Use tokio::sync::RwLock not std::sync::RwLock (!432) + Version 0.6.0: 2024-07-27 [ Maxime “pep” Buquet ] * Breaking: diff --git a/xmpp/src/agent.rs b/xmpp/src/agent.rs index 48d39cf3..b172aff6 100644 --- a/xmpp/src/agent.rs +++ b/xmpp/src/agent.rs @@ -5,7 +5,8 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/. use std::path::{Path, PathBuf}; -use std::sync::{Arc, RwLock}; +use std::sync::Arc; +use tokio::sync::RwLock; use tokio_xmpp::connect::ServerConnector; pub use tokio_xmpp::parsers; use tokio_xmpp::parsers::{disco::DiscoInfoResult, message::MessageType}; diff --git a/xmpp/src/builder.rs b/xmpp/src/builder.rs index 73ceaab9..88889bd4 100644 --- a/xmpp/src/builder.rs +++ b/xmpp/src/builder.rs @@ -4,7 +4,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -use std::sync::{Arc, RwLock}; +use std::sync::Arc; +use tokio::sync::RwLock; use tokio_xmpp::connect::ServerConnector; use tokio_xmpp::{ jid::{BareJid, Jid}, diff --git a/xmpp/src/muc/room.rs b/xmpp/src/muc/room.rs index 96f62893..41e82321 100644 --- a/xmpp/src/muc/room.rs +++ b/xmpp/src/muc/room.rs @@ -28,7 +28,12 @@ pub async fn join_room( muc = muc.with_password(password); } - let nick = nick.unwrap_or_else(|| agent.default_nick.read().unwrap().clone()); + let nick = if let Some(nick) = nick { + nick + } else { + agent.default_nick.read().await.clone() + }; + let room_jid = room.with_resource_str(&nick).unwrap(); let mut presence = Presence::new(PresenceType::None).with_to(room_jid); presence.add_payload(muc);