Skip to content

Commit

Permalink
chore: format
Browse files Browse the repository at this point in the history
  • Loading branch information
TroyKomodo committed Jan 16, 2024
1 parent 2c356a6 commit 740f97e
Show file tree
Hide file tree
Showing 18 changed files with 28 additions and 33 deletions.
2 changes: 1 addition & 1 deletion common/src/database/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ pub fn json<T>(row: Json<T>) -> T {

#[inline]
pub fn non_null_vec<T>(vec: Vec<Option<T>>) -> Vec<T> {
vec.into_iter().filter_map(|x| x).collect()
vec.into_iter().flatten().collect()
}
2 changes: 1 addition & 1 deletion common/src/database/query_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl<'args> QueryBuilder<'args> {

pub fn separated(&mut self, sep: &'args str) -> Separated<'_, 'args> {
Separated {
sep: sep.as_ref(),
sep,
first: true,
query_builder: self,
}
Expand Down
2 changes: 1 addition & 1 deletion platform/api/src/api/jwt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl From<Session> for AuthJwtPayload {
user_id: session.user_id,
session_id: session.id,
expiration: Some(session.expires_at),
issued_at: Ulid::from(session.id).datetime().into(),
issued_at: session.id.datetime().into(),
not_before: None,
audience: None,
}
Expand Down
2 changes: 1 addition & 1 deletion platform/api/src/api/v1/gql/guards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub async fn auth_guard<T, G: ApiGlobal>(
let auth = request_context.auth(global).await?;

if let Some(auth) = auth {
if Ulid::from(auth.session.user_id) == user_id || auth.user_permissions.has_permission(RolePermission::Admin) {
if auth.session.user_id == user_id || auth.user_permissions.has_permission(RolePermission::Admin) {
return Ok(field_value);
}
}
Expand Down
2 changes: 1 addition & 1 deletion platform/api/src/api/v1/gql/mutations/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ impl<G: ApiGlobal> AuthMutation<G> {

let user = global
.user_by_id_loader()
.load(request.user_id.into())
.load(request.user_id)
.await
.map_err_ignored_gql("failed to fetch user")?
.ok_or(GqlError::NotFound("user"))?;
Expand Down
2 changes: 1 addition & 1 deletion platform/api/src/api/v1/gql/subscription/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ impl<G: ApiGlobal> UserSubscription<G> {
.await?
.ok_or(GqlError::Auth(AuthError::NotLoggedIn))?;

let user_id: Ulid = auth.session.user_id.into();
let user_id: Ulid = auth.session.user_id;

let mut subscription = global
.subscription_manager()
Expand Down
2 changes: 1 addition & 1 deletion platform/api/src/database/two_fa_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl<G: ApiGlobal> TwoFaRequestActionTrait<G> for Login {
) RETURNING *
"#,
)
.bind(Ulid::from(ulid::Ulid::new()))
.bind(ulid::Ulid::new())
.bind(user_id)
.bind(expires_at)
.build_query_as()
Expand Down
2 changes: 1 addition & 1 deletion platform/image_processor/src/processor/job/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl<'a, G: ImageProcessorGlobal> Job<'a, G> {
}

// delete job
utils::delete_job(&self.global, self.job.id).await?;
utils::delete_job(self.global, self.job.id).await?;

Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion video/api/src/api/access_token/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl ApiRequest<AccessTokenDeleteResponse> for tonic::Request<AccessTokenDeleteR
})?;

deleted_ids.iter().for_each(|id| {
ids_to_delete.remove(&id);
ids_to_delete.remove(id);
});

deleted_ids
Expand Down
2 changes: 1 addition & 1 deletion video/api/src/api/playback_key_pair/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl ApiRequest<PlaybackKeyPairDeleteResponse> for tonic::Request<PlaybackKeyPai
}

deleted_ids.iter().for_each(|id| {
ids_to_delete.remove(&id);
ids_to_delete.remove(id);
});

Ok(tonic::Response::new(PlaybackKeyPairDeleteResponse {
Expand Down
2 changes: 1 addition & 1 deletion video/api/src/api/recording/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ impl ApiRequest<RecordingDeleteResponse> for tonic::Request<RecordingDeleteReque
.collect::<HashMap<_, _>>();

deleted_ids.iter().for_each(|id| {
ids_to_delete.remove(&id);
ids_to_delete.remove(id);
});

common::database::query("DELETE FROM ")
Expand Down
2 changes: 1 addition & 1 deletion video/api/src/api/recording_config/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl ApiRequest<RecordingConfigDeleteResponse> for tonic::Request<RecordingConfi
})?;

deleted_ids.iter().for_each(|id| {
ids_to_delete.remove(&id);
ids_to_delete.remove(id);
});

deleted_ids
Expand Down
2 changes: 1 addition & 1 deletion video/api/src/api/room/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl ApiRequest<RoomDeleteResponse> for tonic::Request<RoomDeleteRequest> {
})?;

deleted_ids.iter().for_each(|id| {
ids_to_delete.remove(&id);
ids_to_delete.remove(id);
});

deleted_ids
Expand Down
2 changes: 1 addition & 1 deletion video/api/src/api/s3_bucket/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl ApiRequest<S3BucketDeleteResponse> for tonic::Request<S3BucketDeleteRequest
})?;

deleted_ids.iter().for_each(|id| {
ids_to_delete.remove(&id);
ids_to_delete.remove(id);
});

deleted_ids
Expand Down
2 changes: 1 addition & 1 deletion video/api/src/api/transcoding_config/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl ApiRequest<TranscodingConfigDeleteResponse> for tonic::Request<TranscodingC
})?;

deleted_ids.iter().for_each(|id| {
ids_to_delete.remove(&id);
ids_to_delete.remove(id);
});

deleted_ids
Expand Down
13 changes: 5 additions & 8 deletions video/cli/src/invoker/direct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,11 @@ impl DirectBackend {
.ok_or_else(|| anyhow::anyhow!("the organization does not exist"))?;

Some(AccessToken {
organization_id: organization_id.into(),
scopes: vec![
AccessTokenScope {
permission: vec![access_token_scope::Permission::Admin as i32],
resource: None,
}
.into(),
],
organization_id,
scopes: vec![AccessTokenScope {
permission: vec![access_token_scope::Permission::Admin as i32],
resource: None,
}],
..Default::default()
})
} else {
Expand Down
14 changes: 6 additions & 8 deletions video/edge/src/edge/stream/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,9 @@ async fn room_playlist<G: EdgeGlobal>(req: Request<Incoming>) -> Result<Response

let room = room.ok_or((StatusCode::NOT_FOUND, "room not found"))?;

let connection_id = Ulid::from(
room.active_ingest_connection_id
.ok_or((StatusCode::NOT_FOUND, "room not found"))?,
);
let connection_id = room
.active_ingest_connection_id
.ok_or((StatusCode::NOT_FOUND, "room not found"))?;

let audio_output = room.audio_output.ok_or((StatusCode::NOT_FOUND, "room not found"))?;

Expand Down Expand Up @@ -751,10 +750,9 @@ async fn room_screenshot<G: EdgeGlobal>(req: Request<Incoming>) -> Result<Respon

let room = room.ok_or((StatusCode::NOT_FOUND, "room not found"))?;

let connection_id = Ulid::from(
room.active_ingest_connection_id
.ok_or((StatusCode::NOT_FOUND, "room not found"))?,
);
let connection_id = room
.active_ingest_connection_id
.ok_or((StatusCode::NOT_FOUND, "room not found"))?;

if room.visibility != Visibility::Public && token.is_none() {
return Err((StatusCode::UNAUTHORIZED, "room is private, token is required").into());
Expand Down
4 changes: 2 additions & 2 deletions video/edge/src/edge/stream/playlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ pub async fn rendition_playlist<G: EdgeGlobal>(
playlist.thumbnails = recording_thumbnails
.into_iter()
.map(|t| ThumbnailRange {
id: format!("{}.{}.jpg", t.idx, Ulid::from(t.id)),
id: format!("{}.{}.jpg", t.idx, t.id),
start_time: normalize_float(t.start_time as f64),
idx: t.idx as u32,
})
Expand All @@ -304,7 +304,7 @@ pub async fn rendition_playlist<G: EdgeGlobal>(
.zip(recording_rendition.segment_start_times.iter().copied())
.zip(recording_rendition.segment_end_times.iter().copied())
.zip(recording_rendition.segment_ids.iter().copied())
.map(|(((idx, start_time), end_time), id)| (idx as u32, start_time, end_time, Ulid::from(id)))
.map(|(((idx, start_time), end_time), id)| (idx as u32, start_time, end_time, id))
.take_while(|(idx, _, _, _)| active_idx.map(|aidx| *idx < aidx).unwrap_or(true))
.enumerate()
{
Expand Down

0 comments on commit 740f97e

Please sign in to comment.