feat: add profile fields for local users

DB→domain→API→AP→frontend end-to-end. Fields stored as
JSONB, exposed via PATCH /users/me, serialized as AP
PropertyValue attachment. Editor in federation settings,
display on profile card.
This commit is contained in:
2026-05-29 13:54:25 +02:00
parent 14a869cc8d
commit 805bd9534f
19 changed files with 224 additions and 27 deletions

View File

@@ -1,7 +1,7 @@
use crate::{deps_struct, errors::ApiError, extractors::Deps};
use api_types::{
requests::{LoginRequest, RegisterRequest},
responses::{AuthResponse, ErrorResponse, UserResponse},
responses::{AuthResponse, ErrorResponse, ProfileField, UserResponse},
};
use application::use_cases::auth::{login, register, LoginInput, RegisterInput};
use axum::{http::StatusCode, response::IntoResponse, Json};
@@ -23,6 +23,14 @@ pub fn to_user_response(u: &domain::models::user::User) -> UserResponse {
avatar_url: u.avatar_url.clone(),
header_url: u.header_url.clone(),
custom_css: u.custom_css.clone(),
profile_fields: u
.profile_fields
.iter()
.map(|(n, v)| ProfileField {
name: n.clone(),
value: v.clone(),
})
.collect(),
local: u.local,
is_followed_by_viewer: false,
created_at: u.created_at,

View File

@@ -114,6 +114,9 @@ pub async fn patch_profile(
avatar_url: body.avatar_url,
header_url: body.header_url,
custom_css: body.custom_css,
profile_fields: body
.profile_fields
.map(|f| f.into_iter().map(|pf| (pf.name, pf.value)).collect()),
},
)
.await?;
@@ -208,6 +211,7 @@ pub async fn get_users(
avatar_url: u.avatar_url.clone(),
header_url: None,
custom_css: None,
profile_fields: vec![],
local: true,
is_followed_by_viewer: false,
created_at: chrono::Utc::now(),