Implement Database::unshare_project
This commit is contained in:
parent
e3ac67784a
commit
944d6554de
1 changed files with 17 additions and 16 deletions
|
@ -1527,22 +1527,23 @@ impl Database {
|
||||||
connection_id: ConnectionId,
|
connection_id: ConnectionId,
|
||||||
) -> Result<RoomGuard<(proto::Room, Vec<ConnectionId>)>> {
|
) -> Result<RoomGuard<(proto::Room, Vec<ConnectionId>)>> {
|
||||||
self.transact(|tx| async move {
|
self.transact(|tx| async move {
|
||||||
todo!()
|
let guest_connection_ids = self.project_guest_connection_ids(project_id, &tx).await?;
|
||||||
// let guest_connection_ids = self.get_guest_connection_ids(project_id, &mut tx).await?;
|
|
||||||
// let room_id: RoomId = sqlx::query_scalar(
|
let project = project::Entity::find_by_id(project_id)
|
||||||
// "
|
.one(&tx)
|
||||||
// DELETE FROM projects
|
.await?
|
||||||
// WHERE id = $1 AND host_connection_id = $2
|
.ok_or_else(|| anyhow!("project not found"))?;
|
||||||
// RETURNING room_id
|
if project.host_connection_id == connection_id.0 as i32 {
|
||||||
// ",
|
let room_id = project.room_id;
|
||||||
// )
|
project::Entity::delete(project.into_active_model())
|
||||||
// .bind(project_id)
|
.exec(&tx)
|
||||||
// .bind(connection_id.0 as i32)
|
.await?;
|
||||||
// .fetch_one(&mut tx)
|
let room = self.get_room(room_id, &tx).await?;
|
||||||
// .await?;
|
self.commit_room_transaction(room_id, tx, (room, guest_connection_ids))
|
||||||
// let room = self.get_room(room_id, &mut tx).await?;
|
.await
|
||||||
// self.commit_room_transaction(room_id, tx, (room, guest_connection_ids))
|
} else {
|
||||||
// .await
|
Err(anyhow!("cannot unshare a project hosted by another user"))?
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue