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 }
|
||||
application = { workspace = true }
|
||||
api-types = { workspace = true }
|
||||
axum = { workspace = true }
|
||||
|
||||
@@ -4,7 +4,6 @@ use crate::{
|
||||
handlers::feed::to_thought_response,
|
||||
state::AppState,
|
||||
};
|
||||
use activitypub::ActivityPubRepository;
|
||||
use api_types::{
|
||||
requests::PaginationQuery,
|
||||
responses::{
|
||||
@@ -18,6 +17,7 @@ use axum::{
|
||||
extract::{Path, Query},
|
||||
Json,
|
||||
};
|
||||
use domain::ports::FederationContentRepository;
|
||||
use domain::{
|
||||
models::feed::PageParams,
|
||||
ports::{
|
||||
@@ -29,7 +29,7 @@ use std::sync::Arc;
|
||||
|
||||
pub struct FederationActorsDeps {
|
||||
pub federation: Arc<dyn FederationActionPort>,
|
||||
pub ap_repo: Arc<dyn ActivityPubRepository>,
|
||||
pub ap_repo: Arc<dyn FederationContentRepository>,
|
||||
pub feed: Arc<dyn FeedRepository>,
|
||||
pub federation_scheduler: Arc<dyn FederationSchedulerPort>,
|
||||
pub remote_actor_connections: Arc<dyn RemoteActorConnectionRepository>,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use activitypub::ActivityPubRepository;
|
||||
use application::use_cases::profile::UploadConfig;
|
||||
use domain::ports::*;
|
||||
use std::sync::Arc;
|
||||
@@ -24,7 +23,7 @@ pub struct AppState {
|
||||
pub events: Arc<dyn EventPublisher>,
|
||||
pub outbox: Arc<dyn OutboxWriter>,
|
||||
pub federation: Arc<dyn FederationActionPort>,
|
||||
pub ap_repo: Arc<dyn ActivityPubRepository>,
|
||||
pub ap_repo: Arc<dyn FederationContentRepository>,
|
||||
pub remote_actor_connections: Arc<dyn RemoteActorConnectionRepository>,
|
||||
pub federation_scheduler: Arc<dyn FederationSchedulerPort>,
|
||||
pub engagement: Arc<dyn EngagementRepository>,
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
use crate::state::AppState;
|
||||
use activitypub::{ActivityPubRepository, ActorApUrls, OutboxEntry};
|
||||
use application::use_cases::profile::UploadConfig;
|
||||
use async_trait::async_trait;
|
||||
use domain::ports::{
|
||||
AcceptNoteInput, ActorFederationUrls, FederationContentRepository, OutboxEntry,
|
||||
};
|
||||
use domain::{
|
||||
errors::DomainError,
|
||||
ports::{AuthService, DataStream, GeneratedToken, MediaStore, PasswordHasher},
|
||||
@@ -34,7 +36,7 @@ impl PasswordHasher for NoOpHasher {
|
||||
pub struct NoOpApRepo;
|
||||
|
||||
#[async_trait]
|
||||
impl ActivityPubRepository for NoOpApRepo {
|
||||
impl FederationContentRepository for NoOpApRepo {
|
||||
async fn outbox_entries_for_actor(&self, _: &UserId) -> Result<Vec<OutboxEntry>, DomainError> {
|
||||
Ok(vec![])
|
||||
}
|
||||
@@ -60,13 +62,15 @@ impl ActivityPubRepository for NoOpApRepo {
|
||||
) -> Result<(), DomainError> {
|
||||
Ok(())
|
||||
}
|
||||
async fn accept_note(
|
||||
&self,
|
||||
_: activitypub::AcceptNoteInput<'_>,
|
||||
) -> Result<ThoughtId, DomainError> {
|
||||
async fn accept_note(&self, _: AcceptNoteInput<'_>) -> Result<ThoughtId, DomainError> {
|
||||
Ok(ThoughtId::from_uuid(uuid::Uuid::new_v4()))
|
||||
}
|
||||
async fn apply_note_update(&self, _: &str, _: &str, _: Option<serde_json::Value>) -> Result<(), DomainError> {
|
||||
async fn apply_note_update(
|
||||
&self,
|
||||
_: &str,
|
||||
_: &str,
|
||||
_: Option<serde_json::Value>,
|
||||
) -> Result<(), DomainError> {
|
||||
Ok(())
|
||||
}
|
||||
async fn retract_note(&self, _: &str) -> Result<(), DomainError> {
|
||||
@@ -81,7 +85,10 @@ impl ActivityPubRepository for NoOpApRepo {
|
||||
async fn get_thought_ap_id(&self, _: &ThoughtId) -> Result<Option<String>, DomainError> {
|
||||
Ok(None)
|
||||
}
|
||||
async fn get_actor_ap_urls(&self, _: &UserId) -> Result<Option<ActorApUrls>, DomainError> {
|
||||
async fn get_actor_ap_urls(
|
||||
&self,
|
||||
_: &UserId,
|
||||
) -> Result<Option<ActorFederationUrls>, DomainError> {
|
||||
Ok(None)
|
||||
}
|
||||
async fn sync_remote_actor_to_user(&self, _: &str) -> Result<(), DomainError> {
|
||||
|
||||
Reference in New Issue
Block a user