Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

Commit

Permalink
Move max room duration into config (#244)
Browse files Browse the repository at this point in the history
  • Loading branch information
feymartynov committed May 20, 2021
1 parent f94be0c commit ca721bb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
20 changes: 10 additions & 10 deletions src/app/endpoint/rtc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ pub(crate) type ConnectResponse = OutgoingResponse<ConnectResponseData>;

////////////////////////////////////////////////////////////////////////////////

const MAX_WEBINAR_DURATION: i64 = 7;

#[derive(Debug, Deserialize)]
pub(crate) struct CreateRequest {
room_id: Uuid,
Expand Down Expand Up @@ -79,15 +77,17 @@ impl RequestHandler for CreateHandler {
let conn = context.get_conn()?;

conn.transaction::<_, diesel::result::Error, _>(|| {
if let (start, Bound::Unbounded) = room.time() {
let new_time = (
*start,
Bound::Excluded(Utc::now() + Duration::hours(MAX_WEBINAR_DURATION)),
);
if let Some(max_room_duration) = context.config().max_room_duration {
if let (start, Bound::Unbounded) = room.time() {
let new_time = (
*start,
Bound::Excluded(Utc::now() + Duration::hours(max_room_duration)),
);

db::room::UpdateQuery::new(room.id())
.time(Some(new_time))
.execute(&conn)?;
db::room::UpdateQuery::new(room.id())
.time(Some(new_time))
.execute(&conn)?;
}
}

let rtc =
Expand Down
1 change: 1 addition & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub(crate) struct Config {
#[serde(default)]
pub(crate) kruonis: KruonisConfig,
pub(crate) metrics: Option<MetricsConfig>,
pub(crate) max_room_duration: Option<i64>,
}

#[derive(Clone, Debug, Deserialize)]
Expand Down
3 changes: 2 additions & 1 deletion src/test_helpers/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ fn build_config() -> Config {
"bucket": format!("origin.minigroup.{}", USR_AUDIENCE),
}
}
}
},
"max_room_duration": 7,
});

serde_json::from_value::<Config>(config).expect("Failed to parse test config")
Expand Down

0 comments on commit ca721bb

Please sign in to comment.