feat: expose display_name, also_known_as, profile fields in GET /profile

This commit is contained in:
2026-06-04 02:58:12 +02:00
parent cf2f4a1b4f
commit 15dc0e526b
3 changed files with 33 additions and 0 deletions

View File

@@ -84,9 +84,12 @@ pub struct UserProfileResponse {
#[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)]
pub struct ProfileResponse {
pub username: String,
pub display_name: Option<String>,
pub bio: Option<String>,
pub avatar_url: Option<String>,
pub banner_url: Option<String>,
pub also_known_as: Option<String>,
pub fields: Vec<ProfileFieldDto>,
pub role: String,
}

View File

@@ -2,11 +2,19 @@ use domain::errors::DomainError;
use crate::{context::AppContext, users::queries::GetCurrentProfileQuery};
pub struct ProfileFieldData {
pub name: String,
pub value: String,
}
pub struct CurrentProfileData {
pub username: String,
pub display_name: Option<String>,
pub bio: Option<String>,
pub avatar_url: Option<String>,
pub banner_url: Option<String>,
pub also_known_as: Option<String>,
pub fields: Vec<ProfileFieldData>,
pub role: String,
}
@@ -29,11 +37,23 @@ pub async fn execute(
.banner_path()
.map(|path| format!("{}/images/{}", ctx.config.base_url, path));
let fields = user
.profile_fields()
.iter()
.map(|f| ProfileFieldData {
name: f.name.clone(),
value: f.value.clone(),
})
.collect();
Ok(CurrentProfileData {
username: user.username().value().to_string(),
display_name: user.display_name().map(|s| s.to_string()),
bio: user.bio().map(|s| s.to_string()),
avatar_url,
banner_url,
also_known_as: user.also_known_as().map(|s| s.to_string()),
fields,
role: user.role().as_str().into(),
})
}

View File

@@ -414,9 +414,19 @@ pub async fn get_profile(
.await?;
Ok(Json(ProfileResponse {
username: profile.username,
display_name: profile.display_name,
bio: profile.bio,
avatar_url: profile.avatar_url,
banner_url: profile.banner_url,
also_known_as: profile.also_known_as,
fields: profile
.fields
.into_iter()
.map(|f| api_types::ProfileFieldDto {
name: f.name,
value: f.value,
})
.collect(),
role: profile.role,
}))
}