refactor: replace long arg lists with input/config structs and builder

- Thought::new_local → NewThought struct (7 args → 1)
- UserWriter::update_profile → UpdateProfileInput struct (6 args → 2)
- update_profile use case → UpdateProfileInput (8 args → 3)
- ActivityPubService::new → builder pattern (9 args → 5 required + 4 optional setters)
- accept_note → AcceptNoteInput struct (8 args → 1)
- ThoughtNote::new_public → ThoughtNoteInput struct (8 args → 1)

Remove all #[allow(clippy::too_many_arguments)] annotations.
This commit is contained in:
2026-05-17 12:25:53 +02:00
parent 2f5c89c381
commit d56d34cc27
31 changed files with 449 additions and 450 deletions

View File

@@ -4,7 +4,7 @@ use chrono::{DateTime, Utc};
use domain::{
errors::DomainError,
models::feed::{PageParams, Paginated, UserSummary},
models::user::User,
models::user::{UpdateProfileInput, User},
ports::{UserReader, UserWriter},
value_objects::{Email, PasswordHash, UserId, Username},
};
@@ -265,21 +265,17 @@ impl UserWriter for PgUserRepository {
async fn update_profile(
&self,
user_id: &UserId,
display_name: Option<String>,
bio: Option<String>,
avatar_url: Option<String>,
header_url: Option<String>,
custom_css: Option<String>,
input: UpdateProfileInput,
) -> Result<(), DomainError> {
sqlx::query(
"UPDATE users SET display_name=$2,bio=$3,avatar_url=$4,header_url=$5,custom_css=$6,updated_at=NOW() WHERE id=$1"
)
.bind(user_id.as_uuid())
.bind(display_name)
.bind(bio)
.bind(avatar_url)
.bind(header_url)
.bind(custom_css)
.bind(input.display_name)
.bind(input.bio)
.bind(input.avatar_url)
.bind(input.header_url)
.bind(input.custom_css)
.execute(&self.pool)
.await
.into_domain()

View File

@@ -1,5 +1,8 @@
use super::*;
use domain::{models::user::User, value_objects::*};
use domain::{
models::user::{UpdateProfileInput, User},
value_objects::*,
};
#[sqlx::test(migrations = "./migrations")]
async fn save_and_find_by_id(pool: sqlx::PgPool) {
@@ -55,11 +58,11 @@ async fn update_profile_changes_fields(pool: sqlx::PgPool) {
repo.save(&user).await.unwrap();
repo.update_profile(
&user.id,
Some("Charlie".into()),
Some("bio".into()),
None,
None,
None,
UpdateProfileInput {
display_name: Some("Charlie".into()),
bio: Some("bio".into()),
..Default::default()
},
)
.await
.unwrap();