mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-09 12:01:58 +00:00
Delete empty rooms
This commit is contained in:
parent
27f6ae945d
commit
568de814aa
1 changed files with 25 additions and 4 deletions
|
@ -123,6 +123,18 @@ impl Database {
|
||||||
.filter(project::Column::HostConnectionEpoch.ne(self.epoch))
|
.filter(project::Column::HostConnectionEpoch.ne(self.epoch))
|
||||||
.exec(&tx)
|
.exec(&tx)
|
||||||
.await?;
|
.await?;
|
||||||
|
room::Entity::delete_many()
|
||||||
|
.filter(
|
||||||
|
room::Column::Id.not_in_subquery(
|
||||||
|
Query::select()
|
||||||
|
.column(room_participant::Column::RoomId)
|
||||||
|
.from(room_participant::Entity)
|
||||||
|
.distinct()
|
||||||
|
.to_owned(),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.exec(&tx)
|
||||||
|
.await?;
|
||||||
tx.commit().await?;
|
tx.commit().await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
|
@ -1272,8 +1284,12 @@ impl Database {
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let room = self.get_room(room_id, &tx).await?;
|
let room = self.get_room(room_id, &tx).await?;
|
||||||
Ok(Some(
|
if room.participants.is_empty() {
|
||||||
self.commit_room_transaction(
|
room::Entity::delete_by_id(room_id).exec(&tx).await?;
|
||||||
|
}
|
||||||
|
|
||||||
|
let left_room = self
|
||||||
|
.commit_room_transaction(
|
||||||
room_id,
|
room_id,
|
||||||
tx,
|
tx,
|
||||||
LeftRoom {
|
LeftRoom {
|
||||||
|
@ -1282,8 +1298,13 @@ impl Database {
|
||||||
canceled_calls_to_user_ids,
|
canceled_calls_to_user_ids,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.await?,
|
.await?;
|
||||||
))
|
|
||||||
|
if left_room.room.participants.is_empty() {
|
||||||
|
self.rooms.remove(&room_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(Some(left_room))
|
||||||
} else {
|
} else {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue