Rename connection_lost to answering_connection_lost

This commit is contained in:
Antonio Scandurra 2022-12-09 14:08:40 +01:00
parent 26b5653427
commit 456396ca6e
5 changed files with 10 additions and 9 deletions

View File

@ -118,7 +118,7 @@ CREATE TABLE "room_participants" (
"user_id" INTEGER NOT NULL REFERENCES users (id),
"answering_connection_id" INTEGER,
"answering_connection_epoch" TEXT,
"connection_lost" BOOLEAN NOT NULL,
"answering_connection_lost" BOOLEAN NOT NULL,
"location_kind" INTEGER,
"location_project_id" INTEGER,
"initial_project_id" INTEGER,

View File

@ -1,2 +1,2 @@
ALTER TABLE "room_participants"
ADD "connection_lost" BOOLEAN NOT NULL DEFAULT FALSE;
ADD "answering_connection_lost" BOOLEAN NOT NULL DEFAULT FALSE;

View File

@ -1034,7 +1034,7 @@ impl Database {
user_id: ActiveValue::set(user_id),
answering_connection_id: ActiveValue::set(Some(connection_id.0 as i32)),
answering_connection_epoch: ActiveValue::set(Some(self.epoch)),
connection_lost: ActiveValue::set(false),
answering_connection_lost: ActiveValue::set(false),
calling_user_id: ActiveValue::set(user_id),
calling_connection_id: ActiveValue::set(connection_id.0 as i32),
calling_connection_epoch: ActiveValue::set(self.epoch),
@ -1061,7 +1061,7 @@ impl Database {
room_participant::ActiveModel {
room_id: ActiveValue::set(room_id),
user_id: ActiveValue::set(called_user_id),
connection_lost: ActiveValue::set(false),
answering_connection_lost: ActiveValue::set(false),
calling_user_id: ActiveValue::set(calling_user_id),
calling_connection_id: ActiveValue::set(calling_connection_id.0 as i32),
calling_connection_epoch: ActiveValue::set(self.epoch),
@ -1180,13 +1180,13 @@ impl Database {
.and(
room_participant::Column::AnsweringConnectionId
.is_null()
.or(room_participant::Column::ConnectionLost.eq(true)),
.or(room_participant::Column::AnsweringConnectionLost.eq(true)),
),
)
.set(room_participant::ActiveModel {
answering_connection_id: ActiveValue::set(Some(connection_id.0 as i32)),
answering_connection_epoch: ActiveValue::set(Some(self.epoch)),
connection_lost: ActiveValue::set(false),
answering_connection_lost: ActiveValue::set(false),
..Default::default()
})
.exec(&*tx)
@ -1387,7 +1387,7 @@ impl Database {
let room_id = participant.room_id;
room_participant::Entity::update(room_participant::ActiveModel {
connection_lost: ActiveValue::set(true),
answering_connection_lost: ActiveValue::set(true),
..participant.into_active_model()
})
.exec(&*tx)

View File

@ -10,7 +10,7 @@ pub struct Model {
pub user_id: UserId,
pub answering_connection_id: Option<i32>,
pub answering_connection_epoch: Option<Uuid>,
pub connection_lost: bool,
pub answering_connection_lost: bool,
pub location_kind: Option<i32>,
pub location_project_id: Option<ProjectId>,
pub initial_project_id: Option<ProjectId>,

View File

@ -658,11 +658,12 @@ async fn sign_out(
.await
.remove_connection(session.connection_id)?;
if let Ok(mut left_projects) = session
if let Some(mut left_projects) = session
.db()
.await
.connection_lost(session.connection_id)
.await
.trace_err()
{
for left_project in mem::take(&mut *left_projects) {
project_left(&left_project, &session);