From 15dc0e526b48b1b25704004e9c769ac070333dce Mon Sep 17 00:00:00 2001 From: Gabriel Kaszewski Date: Thu, 4 Jun 2026 02:58:12 +0200 Subject: [PATCH] feat: expose display_name, also_known_as, profile fields in GET /profile --- crates/api-types/src/users.rs | 3 +++ .../src/users/get_current_profile.rs | 20 +++++++++++++++++++ crates/presentation/src/handlers/api.rs | 10 ++++++++++ 3 files changed, 33 insertions(+) diff --git a/crates/api-types/src/users.rs b/crates/api-types/src/users.rs index 42c2355..654ebfe 100644 --- a/crates/api-types/src/users.rs +++ b/crates/api-types/src/users.rs @@ -84,9 +84,12 @@ pub struct UserProfileResponse { #[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)] pub struct ProfileResponse { pub username: String, + pub display_name: Option, pub bio: Option, pub avatar_url: Option, pub banner_url: Option, + pub also_known_as: Option, + pub fields: Vec, pub role: String, } diff --git a/crates/application/src/users/get_current_profile.rs b/crates/application/src/users/get_current_profile.rs index b255890..edaa32f 100644 --- a/crates/application/src/users/get_current_profile.rs +++ b/crates/application/src/users/get_current_profile.rs @@ -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, pub bio: Option, pub avatar_url: Option, pub banner_url: Option, + pub also_known_as: Option, + pub fields: Vec, 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(), }) } diff --git a/crates/presentation/src/handlers/api.rs b/crates/presentation/src/handlers/api.rs index 7568f95..3856d7a 100644 --- a/crates/presentation/src/handlers/api.rs +++ b/crates/presentation/src/handlers/api.rs @@ -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, })) }