server: more robust view original serving

This commit is contained in:
Bill Thiede 2025-04-20 10:01:22 -07:00
parent 5cec8add5e
commit c703be2ca5

View File

@ -149,17 +149,13 @@ async fn view_original(
) -> Result<impl IntoResponse, AppError> {
info!("view_original {id}");
let mid = if id.starts_with("id:") {
id.to_string()
id
} else {
format!("id:{}", id)
format!("id:{id}")
};
let files = nm.files(&mid)?;
let Some(path) = files.first() else {
warn!("failed to find files for message {mid}");
return Ok((StatusCode::NOT_FOUND, mid).into_response());
};
let str = std::fs::read_to_string(&path)?;
Ok(str.into_response())
let bytes = nm.show_original(&mid)?;
let s = String::from_utf8_lossy(&bytes).to_string();
Ok(s.into_response())
}
async fn graphiql() -> impl IntoResponse {