From 081a20ae3152a91b56211e860f4b6c561ffd8e57 Mon Sep 17 00:00:00 2001 From: Gabriel Kaszewski Date: Fri, 10 Jul 2026 00:41:51 +0200 Subject: [PATCH] fix: clippy too-many-args on update_remote_review, use RemoteReviewUpdate struct --- crates/adapters/activitypub/src/lib.rs | 2 +- .../src/remote_review_repository.rs | 21 +++++++------ .../activitypub/src/review_handler.rs | 18 +++++------ .../postgres-federation/src/review.rs | 31 +++++++------------ .../adapters/sqlite-federation/src/review.rs | 31 +++++++------------ 5 files changed, 43 insertions(+), 60 deletions(-) diff --git a/crates/adapters/activitypub/src/lib.rs b/crates/adapters/activitypub/src/lib.rs index fcfcd8d..197ae35 100644 --- a/crates/adapters/activitypub/src/lib.rs +++ b/crates/adapters/activitypub/src/lib.rs @@ -22,7 +22,7 @@ pub use k_ap::{ pub use event_handler::ActivityPubEventHandler; pub use port::{ActivityPubPort, NoopActivityPubService}; -pub use remote_review_repository::RemoteReviewRepository; +pub use remote_review_repository::{RemoteReviewRepository, RemoteReviewUpdate}; pub use review_handler::ReviewObjectHandler; pub use user_adapter::DomainUserRepoAdapter; diff --git a/crates/adapters/activitypub/src/remote_review_repository.rs b/crates/adapters/activitypub/src/remote_review_repository.rs index 391b085..87eeae1 100644 --- a/crates/adapters/activitypub/src/remote_review_repository.rs +++ b/crates/adapters/activitypub/src/remote_review_repository.rs @@ -3,6 +3,16 @@ use async_trait::async_trait; use chrono::NaiveDateTime; use domain::models::Review; +pub struct RemoteReviewUpdate<'a> { + pub ap_id: &'a str, + pub actor_url: &'a str, + pub rating: u8, + pub comment: Option<&'a str>, + pub watched_at: NaiveDateTime, + pub poster_url: Option<&'a str>, + pub watch_medium: Option<&'a str>, +} + #[async_trait] pub trait RemoteReviewRepository: Send + Sync { async fn save_remote_review( @@ -17,16 +27,7 @@ pub trait RemoteReviewRepository: Send + Sync { async fn delete_remote_review(&self, ap_id: &str, actor_url: &str) -> Result<()>; - async fn update_remote_review( - &self, - ap_id: &str, - actor_url: &str, - rating: u8, - comment: Option<&str>, - watched_at: NaiveDateTime, - poster_url: Option<&str>, - watch_medium: Option<&str>, - ) -> Result<()>; + async fn update_remote_review(&self, update: RemoteReviewUpdate<'_>) -> Result<()>; async fn delete_by_actor(&self, actor_url: &str) -> Result<()>; } diff --git a/crates/adapters/activitypub/src/review_handler.rs b/crates/adapters/activitypub/src/review_handler.rs index b1199e2..9960850 100644 --- a/crates/adapters/activitypub/src/review_handler.rs +++ b/crates/adapters/activitypub/src/review_handler.rs @@ -188,15 +188,15 @@ impl ApObjectHandler for ReviewObjectHandler { } self.review_store - .update_remote_review( - ap_id.as_str(), - actor_url.as_str(), - obj.rating.min(5), - obj.comment.as_deref(), - obj.watched_at.naive_utc(), - obj.poster_url.as_deref(), - obj.watch_medium.as_deref(), - ) + .update_remote_review(crate::remote_review_repository::RemoteReviewUpdate { + ap_id: ap_id.as_str(), + actor_url: actor_url.as_str(), + rating: obj.rating.min(5), + comment: obj.comment.as_deref(), + watched_at: obj.watched_at.naive_utc(), + poster_url: obj.poster_url.as_deref(), + watch_medium: obj.watch_medium.as_deref(), + }) .await?; Ok(()) diff --git a/crates/adapters/postgres-federation/src/review.rs b/crates/adapters/postgres-federation/src/review.rs index ba5244f..0db58e2 100644 --- a/crates/adapters/postgres-federation/src/review.rs +++ b/crates/adapters/postgres-federation/src/review.rs @@ -1,4 +1,4 @@ -use activitypub::RemoteReviewRepository; +use activitypub::{RemoteReviewRepository, RemoteReviewUpdate}; use anyhow::{Result, anyhow}; use async_trait::async_trait; use domain::models::{Review, ReviewSource}; @@ -71,37 +71,28 @@ impl RemoteReviewRepository for PostgresFederationRepository { Ok(()) } - async fn update_remote_review( - &self, - ap_id: &str, - actor_url: &str, - rating: u8, - comment: Option<&str>, - watched_at: chrono::NaiveDateTime, - poster_url: Option<&str>, - watch_medium: Option<&str>, - ) -> Result<()> { - let watched_at_str = datetime_to_str(&watched_at); + async fn update_remote_review(&self, u: RemoteReviewUpdate<'_>) -> Result<()> { + let watched_at_str = datetime_to_str(&u.watched_at); sqlx::query( "UPDATE reviews SET rating = $1, comment = $2, watched_at = $3::timestamptz, watch_medium = $4 WHERE ap_id = $5 AND remote_actor_url = $6", ) - .bind(rating as i64) - .bind(comment) + .bind(u.rating as i64) + .bind(u.comment) .bind(&watched_at_str) - .bind(watch_medium) - .bind(ap_id) - .bind(actor_url) + .bind(u.watch_medium) + .bind(u.ap_id) + .bind(u.actor_url) .execute(&self.pool) .await?; - if let Some(url) = poster_url { + if let Some(url) = u.poster_url { sqlx::query( "UPDATE movies SET poster_path = $1 WHERE id = (SELECT movie_id FROM reviews WHERE ap_id = $2 AND remote_actor_url = $3)", ) .bind(url) - .bind(ap_id) - .bind(actor_url) + .bind(u.ap_id) + .bind(u.actor_url) .execute(&self.pool) .await?; } diff --git a/crates/adapters/sqlite-federation/src/review.rs b/crates/adapters/sqlite-federation/src/review.rs index 5527ff0..ae92e3f 100644 --- a/crates/adapters/sqlite-federation/src/review.rs +++ b/crates/adapters/sqlite-federation/src/review.rs @@ -1,4 +1,4 @@ -use activitypub::RemoteReviewRepository; +use activitypub::{RemoteReviewRepository, RemoteReviewUpdate}; use anyhow::{Result, anyhow}; use async_trait::async_trait; use domain::models::{Review, ReviewSource}; @@ -71,37 +71,28 @@ impl RemoteReviewRepository for SqliteFederationRepository { Ok(()) } - async fn update_remote_review( - &self, - ap_id: &str, - actor_url: &str, - rating: u8, - comment: Option<&str>, - watched_at: chrono::NaiveDateTime, - poster_url: Option<&str>, - watch_medium: Option<&str>, - ) -> Result<()> { - let watched_at_str = datetime_to_str(&watched_at); + async fn update_remote_review(&self, u: RemoteReviewUpdate<'_>) -> Result<()> { + let watched_at_str = datetime_to_str(&u.watched_at); sqlx::query( "UPDATE reviews SET rating = ?, comment = ?, watched_at = ?, watch_medium = ? WHERE ap_id = ? AND remote_actor_url = ?", ) - .bind(rating as i64) - .bind(comment) + .bind(u.rating as i64) + .bind(u.comment) .bind(&watched_at_str) - .bind(watch_medium) - .bind(ap_id) - .bind(actor_url) + .bind(u.watch_medium) + .bind(u.ap_id) + .bind(u.actor_url) .execute(&self.pool) .await?; - if let Some(url) = poster_url { + if let Some(url) = u.poster_url { sqlx::query( "UPDATE movies SET poster_path = ? WHERE id = (SELECT movie_id FROM reviews WHERE ap_id = ? AND remote_actor_url = ?)", ) .bind(url) - .bind(ap_id) - .bind(actor_url) + .bind(u.ap_id) + .bind(u.actor_url) .execute(&self.pool) .await?; }