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

@@ -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(),
})
}