cargo clippy fix

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