diff --git a/xmpp/src/lib.rs b/xmpp/src/lib.rs index e259f48472b8bc4736bfe8573ba0d1a1e1a2f83d..cfee73365605170b2e396f3cb54c79541d7f78bf 100644 --- a/xmpp/src/lib.rs +++ b/xmpp/src/lib.rs @@ -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)] mod tests { #[test] diff --git a/xmpp/src/muc/room.rs b/xmpp/src/muc/room.rs index 2037c9ac4eac7a93a267e3217dd7732c7f500b43..493dfe7fd1226bdd500ac61a5a86012e27816127 100644 --- a/xmpp/src/muc/room.rs +++ b/xmpp/src/muc/room.rs @@ -81,7 +81,7 @@ pub async fn join_room<'a>(agent: &mut Agent, settings: JoinRoomSettings<'a>) { 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); 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 // with type="unavailable". 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. // TODO: Should this be optional? The XEP says "MAY", but the method signature requires the arguments.