mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-06-26 08:58:27 +02:00
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,
|
lang: &str,
|
||||||
status: &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.
|
/// Request to leave a chatroom.
|
||||||
|
|
|
@ -13,19 +13,18 @@ use tokio_xmpp::{
|
||||||
BareJid,
|
BareJid,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{Agent, RoomNick};
|
|
||||||
use crate::agent::TokioXmppClient;
|
use crate::agent::TokioXmppClient;
|
||||||
|
use crate::{Agent, RoomNick};
|
||||||
|
|
||||||
pub async fn join_room<C: ServerConnector>(
|
pub async fn join_room<C: ServerConnector>(
|
||||||
agent: &mut Agent<C>,
|
agent: &mut Agent<C>,
|
||||||
room: BareJid,
|
room: BareJid,
|
||||||
nick: Option<String>,
|
nick: &String,
|
||||||
password: Option<String>,
|
password: Option<String>,
|
||||||
lang: &str,
|
lang: &str,
|
||||||
status: &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;
|
let _ = agent.client.send_stanza(presence.into()).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user