Remove channel chat participant when connection is lost

This commit is contained in:
Max Brunsfeld 2023-09-11 17:37:05 -07:00
parent f2112b9aad
commit 1c50587cad
4 changed files with 74 additions and 44 deletions

View file

@ -249,6 +249,29 @@ impl Database {
.await
}
pub async fn channel_buffer_connection_lost(
&self,
connection: ConnectionId,
tx: &DatabaseTransaction,
) -> Result<()> {
channel_buffer_collaborator::Entity::update_many()
.filter(
Condition::all()
.add(channel_buffer_collaborator::Column::ConnectionId.eq(connection.id as i32))
.add(
channel_buffer_collaborator::Column::ConnectionServerId
.eq(connection.owner_id as i32),
),
)
.set(channel_buffer_collaborator::ActiveModel {
connection_lost: ActiveValue::set(true),
..Default::default()
})
.exec(&*tx)
.await?;
Ok(())
}
pub async fn leave_channel_buffers(
&self,
connection: ConnectionId,