refactor: delegate mark_follower_accepted/rejected through k-ap service, remove federation_repo from ApFederationAdapter
This commit is contained in:
6
Cargo.lock
generated
6
Cargo.lock
generated
@@ -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]]
|
||||
|
||||
@@ -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 }
|
||||
|
||||
@@ -209,19 +209,16 @@ async fn webfinger_resolve_actor_url(handle: &str) -> anyhow::Result<String> {
|
||||
pub struct ApFederationAdapter {
|
||||
pub(crate) inner: Arc<ActivityPubService>,
|
||||
pub(crate) connections_repo: Arc<dyn RemoteActorConnectionRepository>,
|
||||
pub(crate) federation_repo: Arc<dyn k_ap::FederationRepository>,
|
||||
}
|
||||
|
||||
impl ApFederationAdapter {
|
||||
pub fn new(
|
||||
inner: Arc<ActivityPubService>,
|
||||
connections_repo: Arc<dyn RemoteActorConnectionRepository>,
|
||||
federation_repo: Arc<dyn k_ap::FederationRepository>,
|
||||
) -> 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()))
|
||||
}
|
||||
|
||||
@@ -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 }
|
||||
|
||||
@@ -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 }
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 }
|
||||
|
||||
@@ -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<dyn OutboundFederationPort>;
|
||||
let ap_repo_worker =
|
||||
|
||||
Reference in New Issue
Block a user