cargo clippy fix
This commit is contained in:
@@ -51,20 +51,20 @@ impl Model {
|
||||
.await
|
||||
}
|
||||
pub async fn get_all_active_sessions(db: &DatabaseConnection) -> Result<Vec<Model>, DbErr> {
|
||||
Ok(Entity::find()
|
||||
Entity::find()
|
||||
.filter(Column::EndedAt.is_null())
|
||||
.all(db)
|
||||
.await?)
|
||||
.await
|
||||
}
|
||||
pub async fn get_active_by_stream_key_id(
|
||||
db: &DatabaseConnection,
|
||||
stream_key_id: i32,
|
||||
) -> Result<Option<Model>, DbErr> {
|
||||
Ok(Entity::find()
|
||||
Entity::find()
|
||||
.filter(Column::StreamKeyId.eq(stream_key_id))
|
||||
.filter(Column::EndedAt.is_null())
|
||||
.one(db)
|
||||
.await?)
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn clean_unended_streams(db: &DatabaseConnection) -> Result<u64, DbErr> {
|
||||
|
||||
@@ -58,18 +58,18 @@ impl Entity {
|
||||
if let Some(x) = sessions {
|
||||
Entity::find_by_id(x.id_user).one(db).await
|
||||
} else {
|
||||
return Ok(None);
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
pub async fn find_by_username(
|
||||
db: &DatabaseConnection,
|
||||
username: String,
|
||||
) -> Result<Option<Model>, DbErr> {
|
||||
let user = Entity::find()
|
||||
|
||||
Entity::find()
|
||||
.filter(Column::Username.eq(username))
|
||||
.one(db)
|
||||
.await;
|
||||
user
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ impl AudioProcesser {
|
||||
pub fn encode(&mut self, frame: AudioFrame) -> Vec<OpusAudioFrame> {
|
||||
let mut samples: Vec<f32> = frame
|
||||
.data
|
||||
.chunks_exact(4)
|
||||
.as_chunks::<4>().0.iter()
|
||||
.map(|b| f32::from_le_bytes([b[0], b[1], b[2], b[3]]))
|
||||
.collect();
|
||||
|
||||
|
||||
@@ -162,16 +162,14 @@ async fn edit_stream_key(
|
||||
}
|
||||
}
|
||||
// Empty values are allowed (they clear the field).
|
||||
if let Some(custom_id) = payload.custom_id.as_deref() {
|
||||
if !custom_id.is_empty() && !valid_charset(custom_id) {
|
||||
if let Some(custom_id) = payload.custom_id.as_deref()
|
||||
&& !custom_id.is_empty() && !valid_charset(custom_id) {
|
||||
return Err(HttpError::BadRequest("invalid custom id".into()));
|
||||
}
|
||||
}
|
||||
if let Some(pwd) = payload.password.as_deref() {
|
||||
if !pwd.is_empty() && !valid_charset(pwd) {
|
||||
if let Some(pwd) = payload.password.as_deref()
|
||||
&& !pwd.is_empty() && !valid_charset(pwd) {
|
||||
return Err(HttpError::BadRequest("invalid password".into()));
|
||||
}
|
||||
}
|
||||
|
||||
let stream_key = stream_key::Entity::find_by_id(payload.id)
|
||||
.one(&state.db)
|
||||
|
||||
Reference in New Issue
Block a user