From d68c6283354f3887586b70e4927765e1d77c0907 Mon Sep 17 00:00:00 2001 From: Gabriel Kaszewski Date: Thu, 28 May 2026 02:45:59 +0200 Subject: [PATCH] refactor: delegate mark_follower_accepted/rejected through k-ap service, remove federation_repo from ApFederationAdapter --- Cargo.lock | 6 +++--- crates/adapters/activitypub/Cargo.toml | 2 +- crates/adapters/activitypub/src/service.rs | 11 ++++------- crates/adapters/postgres-federation/Cargo.toml | 2 +- crates/bootstrap/Cargo.toml | 2 +- crates/bootstrap/src/factory.rs | 9 ++------- crates/worker/Cargo.toml | 2 +- crates/worker/src/factory.rs | 4 +--- 8 files changed, 14 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ca73911..a1c7703 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2015,8 +2015,8 @@ dependencies = [ [[package]] name = "k-ap" -version = "0.1.9" -source = "git+https://git.gabrielkaszewski.dev/GKaszewski/k-ap.git?tag=v0.1.9#432f39cbb4f8d74255a1f614a9bb7c8bbfe11cde" +version = "0.1.10" +source = "git+https://git.gabrielkaszewski.dev/GKaszewski/k-ap.git?tag=v0.1.10#d80cfd0431205498161db8665fd884710866ca95" dependencies = [ "activitypub_federation", "anyhow", @@ -4566,7 +4566,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.61.2", + "windows-sys 0.48.0", ] [[package]] diff --git a/crates/adapters/activitypub/Cargo.toml b/crates/adapters/activitypub/Cargo.toml index eb42235..aafdbd6 100644 --- a/crates/adapters/activitypub/Cargo.toml +++ b/crates/adapters/activitypub/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -k-ap = { git = "https://git.gabrielkaszewski.dev/GKaszewski/k-ap.git", tag = "v0.1.9" } +k-ap = { git = "https://git.gabrielkaszewski.dev/GKaszewski/k-ap.git", tag = "v0.1.10" } domain = { workspace = true } url = { workspace = true } serde = { workspace = true } diff --git a/crates/adapters/activitypub/src/service.rs b/crates/adapters/activitypub/src/service.rs index 067ca0c..335429c 100644 --- a/crates/adapters/activitypub/src/service.rs +++ b/crates/adapters/activitypub/src/service.rs @@ -209,19 +209,16 @@ async fn webfinger_resolve_actor_url(handle: &str) -> anyhow::Result { pub struct ApFederationAdapter { pub(crate) inner: Arc, pub(crate) connections_repo: Arc, - pub(crate) federation_repo: Arc, } impl ApFederationAdapter { pub fn new( inner: Arc, connections_repo: Arc, - federation_repo: Arc, ) -> Self { Self { inner, connections_repo, - federation_repo, } } @@ -816,8 +813,8 @@ impl FederationFollowRequestPort for ApFederationAdapter { user_id: &UserId, actor_url: &str, ) -> Result<(), DomainError> { - self.federation_repo - .update_follower_status(user_id.as_uuid(), actor_url, k_ap::FollowerStatus::Accepted) + self.inner + .mark_follower_accepted(user_id.as_uuid(), actor_url) .await .map_err(|e| DomainError::Internal(e.to_string())) } @@ -827,8 +824,8 @@ impl FederationFollowRequestPort for ApFederationAdapter { user_id: &UserId, actor_url: &str, ) -> Result<(), DomainError> { - self.federation_repo - .remove_follower(user_id.as_uuid(), actor_url) + self.inner + .mark_follower_rejected(user_id.as_uuid(), actor_url) .await .map_err(|e| DomainError::Internal(e.to_string())) } diff --git a/crates/adapters/postgres-federation/Cargo.toml b/crates/adapters/postgres-federation/Cargo.toml index 30cdc17..4045a21 100644 --- a/crates/adapters/postgres-federation/Cargo.toml +++ b/crates/adapters/postgres-federation/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -k-ap = { git = "https://git.gabrielkaszewski.dev/GKaszewski/k-ap.git", tag = "v0.1.9" } +k-ap = { git = "https://git.gabrielkaszewski.dev/GKaszewski/k-ap.git", tag = "v0.1.10" } sqlx = { workspace = true } uuid = { workspace = true } chrono = { workspace = true } diff --git a/crates/bootstrap/Cargo.toml b/crates/bootstrap/Cargo.toml index 2fc9931..1cee4b3 100644 --- a/crates/bootstrap/Cargo.toml +++ b/crates/bootstrap/Cargo.toml @@ -14,7 +14,7 @@ postgres = { workspace = true } postgres-search = { workspace = true } postgres-federation = { workspace = true } activitypub = { workspace = true } -k-ap = { git = "https://git.gabrielkaszewski.dev/GKaszewski/k-ap.git", tag = "v0.1.9" } +k-ap = { git = "https://git.gabrielkaszewski.dev/GKaszewski/k-ap.git", tag = "v0.1.10" } nats = { workspace = true } event-transport = { workspace = true } auth = { workspace = true } diff --git a/crates/bootstrap/src/factory.rs b/crates/bootstrap/src/factory.rs index 3b8616c..e2a6e51 100644 --- a/crates/bootstrap/src/factory.rs +++ b/crates/bootstrap/src/factory.rs @@ -76,10 +76,9 @@ pub async fn build(cfg: &Config) -> Infrastructure { // 3. ActivityPub federation let connections_repo = Arc::new(PgRemoteActorConnectionRepository::new(pool.clone())); - let federation_repo = Arc::new(PostgresFederationRepository::new(pool.clone())); let raw_ap_service = Arc::new( ActivityPubService::builder( - federation_repo.clone(), + Arc::new(PostgresFederationRepository::new(pool.clone())), Arc::new(PostgresApUserRepository::new( pool.clone(), cfg.base_url.clone(), @@ -99,11 +98,7 @@ pub async fn build(cfg: &Config) -> Infrastructure { .await .expect("Failed to build ActivityPubService"), ); - let ap_service = Arc::new(ApFederationAdapter::new( - raw_ap_service, - connections_repo, - federation_repo, - )); + let ap_service = Arc::new(ApFederationAdapter::new(raw_ap_service, connections_repo)); // 4. Storage adapter let storage_cfg = StorageConfig { diff --git a/crates/worker/Cargo.toml b/crates/worker/Cargo.toml index 758984e..2993da0 100644 --- a/crates/worker/Cargo.toml +++ b/crates/worker/Cargo.toml @@ -13,7 +13,7 @@ application = { workspace = true } nats = { workspace = true } event-transport = { workspace = true } event-payload = { workspace = true } -k-ap = { git = "https://git.gabrielkaszewski.dev/GKaszewski/k-ap.git", tag = "v0.1.9" } +k-ap = { git = "https://git.gabrielkaszewski.dev/GKaszewski/k-ap.git", tag = "v0.1.10" } activitypub = { workspace = true } postgres = { workspace = true } postgres-federation = { workspace = true } diff --git a/crates/worker/src/factory.rs b/crates/worker/src/factory.rs index 3cdefef..d7437d0 100644 --- a/crates/worker/src/factory.rs +++ b/crates/worker/src/factory.rs @@ -43,10 +43,9 @@ pub async fn build(database_url: &str, base_url: &str, nats_url: &str) -> Worker // ActivityPub service (for federation fan-out) let connections_repo_worker = Arc::new(PgRemoteActorConnectionRepository::new(pool.clone())); - let federation_repo_worker = Arc::new(PostgresFederationRepository::new(pool.clone())); let raw_ap_service = Arc::new( ActivityPubService::builder( - federation_repo_worker.clone(), + Arc::new(PostgresFederationRepository::new(pool.clone())), Arc::new(PostgresApUserRepository::new( pool.clone(), base_url.to_string(), @@ -67,7 +66,6 @@ pub async fn build(database_url: &str, base_url: &str, nats_url: &str) -> Worker let ap_service = Arc::new(ApFederationAdapter::new( raw_ap_service, connections_repo_worker, - federation_repo_worker, )); let ap_outbound = ap_service.clone() as Arc; let ap_repo_worker =