Rename release channel to enviroment

This commit is contained in:
Mikayla 2023-10-10 13:23:03 -07:00
parent 40430cf01b
commit d7d027bcf1
No known key found for this signature in database
5 changed files with 11 additions and 11 deletions

View file

@ -37,7 +37,7 @@ CREATE INDEX "index_contacts_user_id_b" ON "contacts" ("user_id_b");
CREATE TABLE "rooms" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
"live_kit_room" VARCHAR NOT NULL,
"release_channel" VARCHAR,
"enviroment" VARCHAR,
"channel_id" INTEGER REFERENCES channels (id) ON DELETE CASCADE
);
CREATE UNIQUE INDEX "index_rooms_on_channel_id" ON "rooms" ("channel_id");

View file

@ -1 +1 @@
ALTER TABLE rooms ADD COLUMN release_channel TEXT;
ALTER TABLE rooms ADD COLUMN enviroment TEXT;

View file

@ -802,7 +802,7 @@ impl Database {
let result = room::Entity::insert(room::ActiveModel {
channel_id: ActiveValue::Set(Some(channel_id)),
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()
})
.exec(&*tx)

View file

@ -112,7 +112,7 @@ impl Database {
self.transaction(|tx| async move {
let room = room::ActiveModel {
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()
}
.insert(&*tx)
@ -272,28 +272,28 @@ impl Database {
room_id: RoomId,
user_id: UserId,
connection: ConnectionId,
collab_release_channel: &str,
enviroment: &str,
) -> Result<RoomGuard<JoinRoom>> {
self.room_transaction(room_id, |tx| async move {
#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)]
enum QueryChannelIdAndReleaseChannel {
enum QueryChannelIdAndEnviroment {
ChannelId,
ReleaseChannel,
Enviroment,
}
let (channel_id, release_channel): (Option<ChannelId>, Option<String>) =
room::Entity::find()
.select_only()
.column(room::Column::ChannelId)
.column(room::Column::ReleaseChannel)
.column(room::Column::Enviroment)
.filter(room::Column::Id.eq(room_id))
.into_values::<_, QueryChannelIdAndReleaseChannel>()
.into_values::<_, QueryChannelIdAndEnviroment>()
.one(&*tx)
.await?
.ok_or_else(|| anyhow!("no such room"))?;
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))?;
}
}

View file

@ -8,7 +8,7 @@ pub struct Model {
pub id: RoomId,
pub live_kit_room: String,
pub channel_id: Option<ChannelId>,
pub release_channel: Option<String>,
pub enviroment: Option<String>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]