Rename release channel to enviroment
This commit is contained in:
parent
40430cf01b
commit
d7d027bcf1
5 changed files with 11 additions and 11 deletions
|
@ -37,7 +37,7 @@ CREATE INDEX "index_contacts_user_id_b" ON "contacts" ("user_id_b");
|
||||||
CREATE TABLE "rooms" (
|
CREATE TABLE "rooms" (
|
||||||
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
|
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
"live_kit_room" VARCHAR NOT NULL,
|
"live_kit_room" VARCHAR NOT NULL,
|
||||||
"release_channel" VARCHAR,
|
"enviroment" VARCHAR,
|
||||||
"channel_id" INTEGER REFERENCES channels (id) ON DELETE CASCADE
|
"channel_id" INTEGER REFERENCES channels (id) ON DELETE CASCADE
|
||||||
);
|
);
|
||||||
CREATE UNIQUE INDEX "index_rooms_on_channel_id" ON "rooms" ("channel_id");
|
CREATE UNIQUE INDEX "index_rooms_on_channel_id" ON "rooms" ("channel_id");
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
ALTER TABLE rooms ADD COLUMN release_channel TEXT;
|
ALTER TABLE rooms ADD COLUMN enviroment TEXT;
|
||||||
|
|
|
@ -802,7 +802,7 @@ impl Database {
|
||||||
let result = room::Entity::insert(room::ActiveModel {
|
let result = room::Entity::insert(room::ActiveModel {
|
||||||
channel_id: ActiveValue::Set(Some(channel_id)),
|
channel_id: ActiveValue::Set(Some(channel_id)),
|
||||||
live_kit_room: ActiveValue::Set(live_kit_room.to_string()),
|
live_kit_room: ActiveValue::Set(live_kit_room.to_string()),
|
||||||
release_channel: ActiveValue::Set(Some(enviroment.to_string())),
|
enviroment: ActiveValue::Set(Some(enviroment.to_string())),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
})
|
||||||
.exec(&*tx)
|
.exec(&*tx)
|
||||||
|
|
|
@ -112,7 +112,7 @@ impl Database {
|
||||||
self.transaction(|tx| async move {
|
self.transaction(|tx| async move {
|
||||||
let room = room::ActiveModel {
|
let room = room::ActiveModel {
|
||||||
live_kit_room: ActiveValue::set(live_kit_room.into()),
|
live_kit_room: ActiveValue::set(live_kit_room.into()),
|
||||||
release_channel: ActiveValue::set(Some(release_channel.to_string())),
|
enviroment: ActiveValue::set(Some(release_channel.to_string())),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
.insert(&*tx)
|
.insert(&*tx)
|
||||||
|
@ -272,28 +272,28 @@ impl Database {
|
||||||
room_id: RoomId,
|
room_id: RoomId,
|
||||||
user_id: UserId,
|
user_id: UserId,
|
||||||
connection: ConnectionId,
|
connection: ConnectionId,
|
||||||
collab_release_channel: &str,
|
enviroment: &str,
|
||||||
) -> Result<RoomGuard<JoinRoom>> {
|
) -> Result<RoomGuard<JoinRoom>> {
|
||||||
self.room_transaction(room_id, |tx| async move {
|
self.room_transaction(room_id, |tx| async move {
|
||||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)]
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)]
|
||||||
enum QueryChannelIdAndReleaseChannel {
|
enum QueryChannelIdAndEnviroment {
|
||||||
ChannelId,
|
ChannelId,
|
||||||
ReleaseChannel,
|
Enviroment,
|
||||||
}
|
}
|
||||||
|
|
||||||
let (channel_id, release_channel): (Option<ChannelId>, Option<String>) =
|
let (channel_id, release_channel): (Option<ChannelId>, Option<String>) =
|
||||||
room::Entity::find()
|
room::Entity::find()
|
||||||
.select_only()
|
.select_only()
|
||||||
.column(room::Column::ChannelId)
|
.column(room::Column::ChannelId)
|
||||||
.column(room::Column::ReleaseChannel)
|
.column(room::Column::Enviroment)
|
||||||
.filter(room::Column::Id.eq(room_id))
|
.filter(room::Column::Id.eq(room_id))
|
||||||
.into_values::<_, QueryChannelIdAndReleaseChannel>()
|
.into_values::<_, QueryChannelIdAndEnviroment>()
|
||||||
.one(&*tx)
|
.one(&*tx)
|
||||||
.await?
|
.await?
|
||||||
.ok_or_else(|| anyhow!("no such room"))?;
|
.ok_or_else(|| anyhow!("no such room"))?;
|
||||||
|
|
||||||
if let Some(release_channel) = release_channel {
|
if let Some(release_channel) = release_channel {
|
||||||
if &release_channel != collab_release_channel {
|
if &release_channel != enviroment {
|
||||||
Err(anyhow!("must join using the {} release", release_channel))?;
|
Err(anyhow!("must join using the {} release", release_channel))?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ pub struct Model {
|
||||||
pub id: RoomId,
|
pub id: RoomId,
|
||||||
pub live_kit_room: String,
|
pub live_kit_room: String,
|
||||||
pub channel_id: Option<ChannelId>,
|
pub channel_id: Option<ChannelId>,
|
||||||
pub release_channel: Option<String>,
|
pub enviroment: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue