Implement Room::set_location
This commit is contained in:
parent
1e45198b9f
commit
456dde200c
8 changed files with 256 additions and 2 deletions
|
@ -585,6 +585,37 @@ impl Store {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn update_participant_location(
|
||||
&mut self,
|
||||
room_id: RoomId,
|
||||
location: proto::ParticipantLocation,
|
||||
connection_id: ConnectionId,
|
||||
) -> Result<&proto::Room> {
|
||||
let room = self
|
||||
.rooms
|
||||
.get_mut(&room_id)
|
||||
.ok_or_else(|| anyhow!("no such room"))?;
|
||||
if let Some(proto::participant_location::Variant::Project(project)) =
|
||||
location.variant.as_ref()
|
||||
{
|
||||
anyhow::ensure!(
|
||||
room.participants
|
||||
.iter()
|
||||
.any(|participant| participant.project_ids.contains(&project.id)),
|
||||
"no such project"
|
||||
);
|
||||
}
|
||||
|
||||
let participant = room
|
||||
.participants
|
||||
.iter_mut()
|
||||
.find(|participant| participant.peer_id == connection_id.0)
|
||||
.ok_or_else(|| anyhow!("no such room"))?;
|
||||
participant.location = Some(location);
|
||||
|
||||
Ok(room)
|
||||
}
|
||||
|
||||
pub fn share_project(
|
||||
&mut self,
|
||||
room_id: RoomId,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue