xmpp: Implement Deref<Target=ResourcePart> for RoomNick
This commit is contained in:
parent
793b76d0d5
commit
c1a3c85556
2 changed files with 10 additions and 2 deletions
|
|
@ -85,6 +85,14 @@ impl core::str::FromStr for RoomNick {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl core::ops::Deref for RoomNick {
|
||||||
|
type Target = ResourcePart;
|
||||||
|
|
||||||
|
fn deref(&self) -> &ResourcePart {
|
||||||
|
&self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ pub async fn join_room<'a>(agent: &mut Agent, settings: JoinRoomSettings<'a>) {
|
||||||
agent.default_nick.read().await.clone()
|
agent.default_nick.read().await.clone()
|
||||||
};
|
};
|
||||||
|
|
||||||
let room_jid = room.with_resource(nick.as_ref());
|
let room_jid = room.with_resource(&nick);
|
||||||
let mut presence = Presence::new(PresenceType::None).with_to(room_jid);
|
let mut presence = Presence::new(PresenceType::None).with_to(room_jid);
|
||||||
presence.add_payload(muc);
|
presence.add_payload(muc);
|
||||||
|
|
||||||
|
|
@ -139,7 +139,7 @@ pub async fn leave_room<'a>(agent: &mut Agent, settings: LeaveRoomSettings<'a>)
|
||||||
// XEP-0045 specifies that, to leave a room, the client must send a presence stanza
|
// XEP-0045 specifies that, to leave a room, the client must send a presence stanza
|
||||||
// with type="unavailable".
|
// with type="unavailable".
|
||||||
let mut presence =
|
let mut presence =
|
||||||
Presence::new(PresenceType::Unavailable).with_to(room.with_resource(nickname.as_ref()));
|
Presence::new(PresenceType::Unavailable).with_to(room.with_resource(&nickname));
|
||||||
|
|
||||||
// Optionally, the client may include a status message in the presence stanza.
|
// Optionally, the client may include a status message in the presence stanza.
|
||||||
// TODO: Should this be optional? The XEP says "MAY", but the method signature requires the arguments.
|
// TODO: Should this be optional? The XEP says "MAY", but the method signature requires the arguments.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue