feat: add PATCH /federation/me/also-known-as endpoint

Adds alsoKnownAs column to users table (migration 013), reads it in
the AP actor JSON, and exposes PATCH /federation/me/also-known-as to
set or clear it. Required pre-condition for broadcast_move.
This commit is contained in:
2026-05-28 01:59:35 +02:00
parent fc290dc18f
commit 2445cad1c9
8 changed files with 92 additions and 11 deletions

View File

@@ -0,0 +1 @@
ALTER TABLE users ADD COLUMN IF NOT EXISTS also_known_as TEXT;

View File

@@ -269,12 +269,12 @@ impl UserWriter for PgUserRepository {
) -> Result<(), DomainError> {
sqlx::query(
"UPDATE users SET \
display_name = COALESCE($2, display_name), \
bio = COALESCE($3, bio), \
avatar_url = COALESCE($4, avatar_url), \
header_url = COALESCE($5, header_url), \
custom_css = COALESCE($6, custom_css), \
updated_at = NOW() \
display_name = COALESCE($2, display_name), \
bio = COALESCE($3, bio), \
avatar_url = COALESCE($4, avatar_url), \
header_url = COALESCE($5, header_url), \
custom_css = COALESCE($6, custom_css), \
updated_at = NOW() \
WHERE id = $1",
)
.bind(user_id.as_uuid())
@@ -288,6 +288,20 @@ impl UserWriter for PgUserRepository {
.into_domain()
.map(|_| ())
}
async fn set_also_known_as(
&self,
user_id: &UserId,
value: Option<String>,
) -> Result<(), DomainError> {
sqlx::query("UPDATE users SET also_known_as = $2, updated_at = NOW() WHERE id = $1")
.bind(user_id.as_uuid())
.bind(value)
.execute(&self.pool)
.await
.into_domain()
.map(|_| ())
}
}
#[cfg(test)]