mirror of https://gitlab.com/xmpp-rs/xmpp-rs.git
Moved the optionality of the nickname to Agent instead of the lower-level method.
This commit is contained in:
parent
857115d0de
commit
ffff9ae618
|
@ -36,7 +36,9 @@ impl<C: ServerConnector> Agent<C> {
|
|||
lang: &str,
|
||||
status: &str,
|
||||
) {
|
||||
muc::room::join_room(self, room, nick, password, lang, status).await
|
||||
// Use the provided nickname, or the default if none.
|
||||
let nick = nick.unwrap_or_else(|| self.default_nick.read().unwrap().to_string());
|
||||
muc::room::join_room(self, room, &nick, password, lang, status).await
|
||||
}
|
||||
|
||||
/// Request to leave a chatroom.
|
||||
|
|
|
@ -13,19 +13,18 @@ use tokio_xmpp::{
|
|||
BareJid,
|
||||
};
|
||||
|
||||
use crate::{Agent, RoomNick};
|
||||
use crate::agent::TokioXmppClient;
|
||||
use crate::{Agent, RoomNick};
|
||||
|
||||
pub async fn join_room<C: ServerConnector>(
|
||||
agent: &mut Agent<C>,
|
||||
room: BareJid,
|
||||
nick: Option<String>,
|
||||
nick: &String,
|
||||
password: Option<String>,
|
||||
lang: &str,
|
||||
status: &str,
|
||||
) {
|
||||
let nick = nick.unwrap_or_else(|| agent.default_nick.read().unwrap().clone());
|
||||
let presence = create_muc_join_presence_stanza(room, password, lang, status, &nick);
|
||||
let presence = create_muc_join_presence_stanza(room, password, lang, status, nick);
|
||||
let _ = agent.client.send_stanza(presence.into()).await;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue