refactor: move federation port types from adapter to domain
ActivityPubRepository→FederationContentRepository, OutboundFederationPort→FederationBroadcastPort, ActorApUrls→ActorFederationUrls. Removes activitypub dep from application and presentation crates. Adapter re-exports old names as aliases for backward compat. Also fixes count_users test broken by instance actor migration.
This commit is contained in:
@@ -5,7 +5,6 @@ edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
domain = { workspace = true }
|
||||
activitypub = { workspace = true }
|
||||
async-trait = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
uuid = { workspace = true }
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
use activitypub::{ActivityPubRepository, OutboundFederationPort};
|
||||
use domain::{
|
||||
errors::DomainError,
|
||||
events::DomainEvent,
|
||||
models::thought::Visibility,
|
||||
ports::{ThoughtRepository, UserReader},
|
||||
ports::{FederationBroadcastPort, FederationContentRepository, ThoughtRepository, UserReader},
|
||||
value_objects::ThoughtId,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
@@ -15,9 +14,9 @@ fn should_broadcast(t: &domain::models::thought::Thought) -> bool {
|
||||
pub struct FederationEventService {
|
||||
pub thoughts: Arc<dyn ThoughtRepository>,
|
||||
pub users: Arc<dyn UserReader>,
|
||||
pub ap: Arc<dyn OutboundFederationPort>,
|
||||
pub ap: Arc<dyn FederationBroadcastPort>,
|
||||
pub base_url: String,
|
||||
pub ap_repo: Arc<dyn ActivityPubRepository>,
|
||||
pub ap_repo: Arc<dyn FederationContentRepository>,
|
||||
}
|
||||
|
||||
impl FederationEventService {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use super::*;
|
||||
use crate::testing::TestApRepo;
|
||||
use activitypub::{ActorApUrls, OutboundFederationPort};
|
||||
use async_trait::async_trait;
|
||||
use domain::ports::{ActorFederationUrls, FederationBroadcastPort};
|
||||
use domain::{
|
||||
errors::DomainError,
|
||||
events::DomainEvent,
|
||||
@@ -27,7 +27,7 @@ struct SpyPort {
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl OutboundFederationPort for SpyPort {
|
||||
impl FederationBroadcastPort for SpyPort {
|
||||
async fn broadcast_create(
|
||||
&self,
|
||||
_: &UserId,
|
||||
@@ -482,7 +482,7 @@ async fn like_added_local_user_remote_thought_broadcasts_like() {
|
||||
let ap_repo = TestApRepo::new(store.clone());
|
||||
ap_repo.actor_ap_urls.lock().unwrap().insert(
|
||||
author.id.clone(),
|
||||
ActorApUrls {
|
||||
ActorFederationUrls {
|
||||
ap_id: "https://mastodon.social/users/author".into(),
|
||||
inbox_url: "https://mastodon.social/users/author/inbox".into(),
|
||||
},
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
/// Test helpers for application-layer tests that need activitypub traits.
|
||||
use activitypub::{ActivityPubRepository, ActorApUrls, OutboxEntry};
|
||||
use async_trait::async_trait;
|
||||
use domain::{
|
||||
errors::DomainError,
|
||||
models::user::User,
|
||||
ports::{AcceptNoteInput, ActorFederationUrls, FederationContentRepository, OutboxEntry},
|
||||
testing::TestStore,
|
||||
value_objects::{Email, ThoughtId, UserId, Username},
|
||||
};
|
||||
@@ -14,8 +13,8 @@ use std::sync::{Arc, Mutex};
|
||||
#[derive(Default, Clone)]
|
||||
pub struct TestApRepo {
|
||||
pub inner: TestStore,
|
||||
/// UserId → ActorApUrls (for get_actor_ap_urls)
|
||||
pub actor_ap_urls: Arc<Mutex<HashMap<UserId, ActorApUrls>>>,
|
||||
/// UserId → ActorFederationUrls (for get_actor_ap_urls)
|
||||
pub actor_ap_urls: Arc<Mutex<HashMap<UserId, ActorFederationUrls>>>,
|
||||
}
|
||||
|
||||
impl TestApRepo {
|
||||
@@ -28,7 +27,7 @@ impl TestApRepo {
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl ActivityPubRepository for TestApRepo {
|
||||
impl FederationContentRepository for TestApRepo {
|
||||
async fn outbox_entries_for_actor(
|
||||
&self,
|
||||
_uid: &UserId,
|
||||
@@ -84,13 +83,15 @@ impl ActivityPubRepository for TestApRepo {
|
||||
) -> Result<(), DomainError> {
|
||||
Ok(())
|
||||
}
|
||||
async fn accept_note(
|
||||
&self,
|
||||
_input: activitypub::AcceptNoteInput<'_>,
|
||||
) -> Result<ThoughtId, DomainError> {
|
||||
async fn accept_note(&self, _input: AcceptNoteInput<'_>) -> Result<ThoughtId, DomainError> {
|
||||
Ok(ThoughtId::from_uuid(uuid::Uuid::new_v4()))
|
||||
}
|
||||
async fn apply_note_update(&self, _ap_id: &str, _new_content: &str, _: Option<serde_json::Value>) -> Result<(), DomainError> {
|
||||
async fn apply_note_update(
|
||||
&self,
|
||||
_ap_id: &str,
|
||||
_new_content: &str,
|
||||
_: Option<serde_json::Value>,
|
||||
) -> Result<(), DomainError> {
|
||||
Ok(())
|
||||
}
|
||||
async fn retract_note(&self, _ap_id: &str) -> Result<(), DomainError> {
|
||||
@@ -124,7 +125,7 @@ impl ActivityPubRepository for TestApRepo {
|
||||
async fn get_actor_ap_urls(
|
||||
&self,
|
||||
user_id: &UserId,
|
||||
) -> Result<Option<ActorApUrls>, DomainError> {
|
||||
) -> Result<Option<ActorFederationUrls>, DomainError> {
|
||||
Ok(self.actor_ap_urls.lock().unwrap().get(user_id).cloned())
|
||||
}
|
||||
async fn sync_remote_actor_to_user(&self, _actor_ap_url: &str) -> Result<(), DomainError> {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use activitypub::ActivityPubRepository;
|
||||
use domain::{
|
||||
errors::DomainError,
|
||||
events::DomainEvent,
|
||||
@@ -8,9 +7,10 @@ use domain::{
|
||||
remote_actor::RemoteActor,
|
||||
},
|
||||
ports::{
|
||||
EventPublisher, FederationActionPort, FederationFollowPort, FederationFollowRequestPort,
|
||||
FederationSchedulerPort, FeedOptions, FeedQuery, FeedRepository, FeedRequest,
|
||||
FollowRepository, RemoteActorConnectionRepository, UserReader, UserWriter,
|
||||
EventPublisher, FederationActionPort, FederationContentRepository, FederationFollowPort,
|
||||
FederationFollowRequestPort, FederationSchedulerPort, FeedOptions, FeedQuery,
|
||||
FeedRepository, FeedRequest, FollowRepository, RemoteActorConnectionRepository, UserReader,
|
||||
UserWriter,
|
||||
},
|
||||
value_objects::UserId,
|
||||
};
|
||||
@@ -119,7 +119,7 @@ pub async fn remove_remote_following(
|
||||
|
||||
pub async fn get_remote_actor_posts(
|
||||
federation: &dyn FederationActionPort,
|
||||
ap_repo: &dyn ActivityPubRepository,
|
||||
ap_repo: &dyn FederationContentRepository,
|
||||
feed: &dyn FeedRepository,
|
||||
scheduler: &dyn FederationSchedulerPort,
|
||||
handle: &str,
|
||||
|
||||
Reference in New Issue
Block a user