test/templates: change new_room signature
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
ce640864ca
commit
ff9e172927
3 changed files with 26 additions and 22 deletions
|
@ -511,8 +511,8 @@ async fn update_joined() {
|
|||
new_room(
|
||||
ROOM1_BARE.clone(),
|
||||
vec![
|
||||
(SUGAKO_FULL1.clone(), SUGAKO_NICK),
|
||||
(PETER_FULL1.clone(), PETER_NICK),
|
||||
(SUGAKO_NICK, vec![SUGAKO_FULL1.clone()]),
|
||||
(PETER_NICK, vec![PETER_FULL1.clone()]),
|
||||
],
|
||||
)
|
||||
.await,
|
||||
|
|
|
@ -150,9 +150,11 @@ async fn leave() {
|
|||
new_room(
|
||||
ROOM1_BARE.clone(),
|
||||
vec![
|
||||
(LOUISE_FULL1.clone(), LOUISE_NICK),
|
||||
(SUGAKO_FULL1.clone(), SUGAKO_NICK),
|
||||
(LOUISE_FULL2.clone(), LOUISE_NICK),
|
||||
(
|
||||
LOUISE_NICK,
|
||||
vec![LOUISE_FULL1.clone(), LOUISE_FULL2.clone()],
|
||||
),
|
||||
(SUGAKO_NICK, vec![SUGAKO_FULL1.clone()]),
|
||||
],
|
||||
)
|
||||
.await,
|
||||
|
|
|
@ -106,27 +106,29 @@ pub fn two_participant_room(roomjid: BareJid) -> Room {
|
|||
|
||||
// TODO: Fix this. Add yet another layer of struct that doesn't send stanzas so we don't need to
|
||||
// duplicate Room code in here without all the safeguards?
|
||||
pub async fn new_room<N: Into<Nick>>(roomjid: BareJid, sessions: Vec<(FullJid, N)>) -> Room {
|
||||
pub async fn new_room<N: Into<Nick>>(roomjid: BareJid, occupants: Vec<(N, Vec<FullJid>)>) -> Room {
|
||||
let mut room = Room::new(roomjid.clone());
|
||||
for (session, nick) in sessions {
|
||||
for (nick, occupant) in occupants {
|
||||
let nick: Nick = nick.into();
|
||||
|
||||
let participant = roomjid.clone().with_resource(nick.clone());
|
||||
let presence = PresenceFull::try_from(
|
||||
Presence::new(PresenceType::None)
|
||||
.with_to(participant)
|
||||
.with_from(session),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
match room.occupants.get_mut(&nick) {
|
||||
Some(occupant) => occupant.add_session(presence).unwrap(),
|
||||
None => {
|
||||
let _ = room
|
||||
.occupants
|
||||
.insert(nick.clone(), Occupant::new(presence).unwrap());
|
||||
}
|
||||
};
|
||||
for session in occupant {
|
||||
let presence = PresenceFull::try_from(
|
||||
Presence::new(PresenceType::None)
|
||||
.with_to(participant.clone())
|
||||
.with_from(session),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
match room.occupants.get_mut(&nick) {
|
||||
Some(occupant) => occupant.add_session(presence).unwrap(),
|
||||
None => {
|
||||
let _ = room
|
||||
.occupants
|
||||
.insert(nick.clone(), Occupant::new(presence).unwrap());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
room
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue