fix: user avatar mime change from gif to avif
This commit is contained in:
parent
ffdb767518
commit
6e0f2985b9
20 changed files with 219 additions and 104 deletions
47
crates/app/src/routes/pages/links.rs
Normal file
47
crates/app/src/routes/pages/links.rs
Normal file
|
@ -0,0 +1,47 @@
|
|||
use axum::{
|
||||
extract::Path,
|
||||
response::{Html, IntoResponse},
|
||||
Extension,
|
||||
};
|
||||
use axum_extra::extract::CookieJar;
|
||||
use tetratto_core::model::{permissions::FinePermission, Error};
|
||||
use crate::{get_user_from_token, State};
|
||||
use super::render_error;
|
||||
|
||||
/// `/links/{id}`
|
||||
pub async fn navigate_request(
|
||||
jar: CookieJar,
|
||||
Path(id): Path<usize>,
|
||||
Extension(data): Extension<State>,
|
||||
) -> impl IntoResponse {
|
||||
let data = data.read().await;
|
||||
let user = match get_user_from_token!(jar, data.0) {
|
||||
Some(ua) => ua,
|
||||
None => {
|
||||
return Err(Html(
|
||||
render_error(Error::NotAllowed, &jar, &data, &None).await,
|
||||
));
|
||||
}
|
||||
};
|
||||
|
||||
let link = match data.0.get_link_by_id(id).await {
|
||||
Ok(x) => x,
|
||||
Err(e) => return Err(Html(render_error(e, &jar, &data, &Some(user)).await)),
|
||||
};
|
||||
|
||||
let owner = match data.0.get_user_by_id(link.owner).await {
|
||||
Ok(x) => x,
|
||||
Err(e) => return Err(Html(render_error(e, &jar, &data, &Some(user)).await)),
|
||||
};
|
||||
|
||||
if owner.permissions.check(FinePermission::SUPPORTER) {
|
||||
if let Err(e) = data.0.incr_link_clicks(link.id).await {
|
||||
return Err(Html(render_error(e, &jar, &data, &Some(user)).await));
|
||||
}
|
||||
}
|
||||
|
||||
Ok(Html(format!(
|
||||
"<!doctype html /><html><head><meta http-equiv=\"refresh\" content=\"0; url={}\" /></head><body>Navigating...</body></html>",
|
||||
link.href
|
||||
)))
|
||||
}
|
|
@ -4,6 +4,7 @@ pub mod communities;
|
|||
pub mod developer;
|
||||
pub mod forge;
|
||||
pub mod journals;
|
||||
pub mod links;
|
||||
pub mod misc;
|
||||
pub mod mod_panel;
|
||||
pub mod profile;
|
||||
|
@ -137,6 +138,8 @@ pub fn routes() -> Router {
|
|||
.route("/journals/{journal}/{note}", get(journals::app_request))
|
||||
.route("/@{owner}/{journal}", get(journals::index_view_request))
|
||||
.route("/@{owner}/{journal}/{note}", get(journals::view_request))
|
||||
// links
|
||||
.route("/links/{id}", get(links::navigate_request))
|
||||
}
|
||||
|
||||
pub async fn render_error(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue