/// Object-storage locator prefix written by every upload endpoint. const STORAGE_SCHEME: &str = "storage://"; /// Browser-facing URL for one space image. /// /// `storage://` locators become the redirect endpoint that hands out a /// presigned object-storage URL, so the database never stores a link with a /// signature on it and no client ever sees a URL that can expire. #[must_use] pub fn resolve_space_image_url( space_lower: &str, kind: &str, raw: Option, ) -> Option { raw.map(|u| { if u.starts_with(STORAGE_SCHEME) { format!("/api/v1/spaces/{space_lower}/images/{kind}/file") } else { u } }) } /// Browser-facing URL for one user avatar. /// /// An empty locator stays empty (the UI renders initials instead), and a /// non-`storage://` value — e.g. an avatar URL imported from another host — /// is passed through untouched. #[must_use] pub fn resolve_user_avatar_url(uid: i64, raw: &str) -> String { if raw.is_empty() { String::new() } else if raw.starts_with(STORAGE_SCHEME) { format!("/api/v1/users/{uid}/avatar") } else { raw.to_string() } }