fix: room attachment upload (Set Uuid::nil, NotFound with msg, Ok wrapper) and silence dead_code warnings
Some checks are pending
CI / Rust Lint & Check (push) Waiting to run
CI / Rust Tests (push) Waiting to run
CI / Frontend Lint & Type Check (push) Waiting to run
CI / Frontend Build (push) Blocked by required conditions

This commit is contained in:
ZhenYi 2026-04-20 19:48:05 +08:00
parent 43e2d26ea2
commit d1e5245e4e
3 changed files with 9 additions and 7 deletions

View File

@ -125,7 +125,7 @@ pub async fn upload(
let key = format!("rooms/{}/{}", room_id, unique_name);
let file_size = file_data.len() as i64;
let url = storage
let _url = storage
.upload(&key, file_data)
.await
.map_err(|e| {
@ -139,7 +139,7 @@ pub async fn upload(
let attachment: room_attachment::ActiveModel = room_attachment::ActiveModel {
id: Set(attachment_id),
room: Set(room_id),
message: Set(None),
message: Set(Uuid::nil()),
uploader: Set(user_id),
file_name: Set(file_name.clone()),
file_size: Set(file_size),
@ -206,11 +206,11 @@ pub async fn get_attachment(
.one(&service.db)
.await
.map_err(|e| crate::error::ApiError(service::error::AppError::InternalServerError(e.to_string())))?
.ok_or_else(|| crate::error::ApiError(service::error::AppError::NotFound))?;
.ok_or_else(|| crate::error::ApiError(service::error::AppError::NotFound("attachment not found".into())))?;
// Ensure the attachment belongs to the requested room
if attachment.room != room_id {
return Err(crate::error::ApiError(service::error::AppError::NotFound));
return Err(crate::error::ApiError(service::error::AppError::NotFound("attachment not found".into())));
}
let storage = service
@ -223,8 +223,8 @@ pub async fn get_attachment(
.await
.map_err(|e| crate::error::ApiError(service::error::AppError::InternalServerError(e.to_string())))?;
HttpResponse::Ok()
.content_type(content_type)
Ok(HttpResponse::Ok()
.content_type(content_type.clone())
.insert_header((
CONTENT_TYPE,
content_type,
@ -233,5 +233,5 @@ pub async fn get_attachment(
CONTENT_DISPOSITION,
format!("inline; filename=\"{}\"", attachment.file_name),
))
.body(data)
.body(data))
}

View File

@ -35,6 +35,7 @@ struct ArxivAuthor {
}
#[derive(Debug, Deserialize)]
#[allow(dead_code)]
struct ArxivLink {
#[serde(rename = "type", default)]
link_type: String,

View File

@ -41,6 +41,7 @@ async fn require_admin(
}
}
#[allow(dead_code)]
fn serde_user(u: &UserModel) -> serde_json::Value {
serde_json::json!({
"id": u.uid.to_string(),