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

@@ -46,24 +46,26 @@ impl Visibility {
}
}
pub struct NewThought {
pub id: ThoughtId,
pub user_id: UserId,
pub content: Content,
pub in_reply_to_id: Option<ThoughtId>,
pub visibility: Visibility,
pub content_warning: Option<String>,
pub sensitive: bool,
}
impl Thought {
pub fn new_local(
id: ThoughtId,
user_id: UserId,
content: Content,
in_reply_to_id: Option<ThoughtId>,
visibility: Visibility,
content_warning: Option<String>,
sensitive: bool,
) -> Self {
pub fn new_local(p: NewThought) -> Self {
Self {
id,
user_id,
content,
in_reply_to_id,
visibility,
content_warning,
sensitive,
id: p.id,
user_id: p.user_id,
content: p.content,
in_reply_to_id: p.in_reply_to_id,
visibility: p.visibility,
content_warning: p.content_warning,
sensitive: p.sensitive,
local: true,
created_at: Utc::now(),
updated_at: None,

View File

@@ -1,6 +1,15 @@
use crate::value_objects::{Email, PasswordHash, UserId, Username};
use chrono::{DateTime, Utc};
#[derive(Debug, Default, Clone)]
pub struct UpdateProfileInput {
pub display_name: Option<String>,
pub bio: Option<String>,
pub avatar_url: Option<String>,
pub header_url: Option<String>,
pub custom_css: Option<String>,
}
#[derive(Debug, Clone)]
pub struct User {
pub id: UserId,

View File

@@ -12,7 +12,7 @@ use crate::{
tag::Tag,
thought::Thought,
top_friend::TopFriend,
user::User,
user::{UpdateProfileInput, User},
},
value_objects::{
ApiKeyId, Content, Email, NotificationId, PasswordHash, ThoughtId, UserId, Username,
@@ -69,11 +69,7 @@ pub trait UserWriter: Send + Sync {
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>;
}

View File

@@ -10,7 +10,7 @@ use crate::{
tag::Tag,
thought::Thought,
top_friend::TopFriend,
user::User,
user::{UpdateProfileInput, User},
},
ports::*,
value_objects::{
@@ -125,11 +125,7 @@ impl UserWriter for TestStore {
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> {
if let Some(u) = self
.users
@@ -138,11 +134,11 @@ impl UserWriter for TestStore {
.iter_mut()
.find(|u| &u.id == user_id)
{
u.display_name = display_name;
u.bio = bio;
u.avatar_url = avatar_url;
u.header_url = header_url;
u.custom_css = custom_css;
u.display_name = input.display_name;
u.bio = input.bio;
u.avatar_url = input.avatar_url;
u.header_url = input.header_url;
u.custom_css = input.custom_css;
}
Ok(())
}