diff --git a/src/main.rs b/src/main.rs index 39a4074..d041fa1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -214,6 +214,19 @@ impl std::str::FromStr for SecretKey { } } +pub struct Urls; +impl hyaenidae_profiles::UrlFor for Urls { + fn profile(&self, profile: &hyaenidae_profiles::store::Profile) -> String { + format!("/profiles/id/{}", profile.id()) + } + + fn icon(&self, file: &hyaenidae_profiles::store::File) -> String { + file.pictrs_key() + .map(|key| images::largest_icon(key, images::ImageType::Png)) + .unwrap_or("/404".to_owned()) + } +} + #[derive(Clone)] struct State { profiles: Arc, @@ -249,6 +262,7 @@ impl State { images.clone(), apub.clone(), spawn.clone(), + Urls, arbiter, db.clone(), )?, diff --git a/src/profiles/mod.rs b/src/profiles/mod.rs index 1890b54..2a88873 100644 --- a/src/profiles/mod.rs +++ b/src/profiles/mod.rs @@ -497,32 +497,10 @@ impl From for crate::pagination::PageSource { } } -async fn id_view( - loader: ActixLoader, - req: HttpRequest, - user: Option, - self_profile: Option, - id: web::Path, - page: Option>, - nav_state: NavState, - state: web::Data, -) -> Result { +async fn id_view(id: web::Path, state: web::Data) -> Result { let profile = profile_from_id(id.into_inner(), &state).await?; - if profile.is_suspended() { - return Ok(crate::to_404()); - } - do_public_view( - loader, - req.uri().path(), - user, - self_profile.map(|p| p.into_inner()), - profile, - page.map(|q| q.into_inner()), - nav_state, - &state, - ) - .await + Ok(crate::redirect(&profile.view_path())) } async fn handle_view(