refactor(ports): CQRS split — FederationActionPort into four focused sub-ports
This commit is contained in:
@@ -230,14 +230,35 @@ pub trait RemoteActorConnectionRepository: Send + Sync {
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
pub trait FederationActionPort: Send + Sync {
|
||||
pub trait FederationLookupPort: Send + Sync {
|
||||
async fn lookup_actor(&self, handle: &str) -> Result<RemoteActor, DomainError>;
|
||||
async fn actor_json(&self, user_id: &UserId) -> Result<String, DomainError>;
|
||||
async fn followers_collection_json(
|
||||
&self,
|
||||
user_id: &UserId,
|
||||
page: Option<u32>,
|
||||
) -> Result<String, DomainError>;
|
||||
async fn following_collection_json(
|
||||
&self,
|
||||
user_id: &UserId,
|
||||
page: Option<u32>,
|
||||
) -> Result<String, DomainError>;
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
pub trait FederationFollowPort: Send + Sync {
|
||||
async fn follow_remote(&self, local_user_id: &UserId, handle: &str) -> Result<(), DomainError>;
|
||||
async fn unfollow_remote(
|
||||
&self,
|
||||
local_user_id: &UserId,
|
||||
handle: &str,
|
||||
) -> Result<(), DomainError>;
|
||||
async fn get_remote_following(&self, user_id: &UserId)
|
||||
-> Result<Vec<RemoteActor>, DomainError>;
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
pub trait FederationFollowRequestPort: Send + Sync {
|
||||
async fn get_pending_followers(
|
||||
&self,
|
||||
user_id: &UserId,
|
||||
@@ -259,36 +280,38 @@ pub trait FederationActionPort: Send + Sync {
|
||||
user_id: &UserId,
|
||||
actor_url: &str,
|
||||
) -> Result<(), DomainError>;
|
||||
async fn get_remote_following(&self, user_id: &UserId)
|
||||
-> Result<Vec<RemoteActor>, DomainError>;
|
||||
async fn actor_json(&self, user_id: &UserId) -> Result<String, DomainError>;
|
||||
async fn followers_collection_json(
|
||||
&self,
|
||||
user_id: &UserId,
|
||||
page: Option<u32>,
|
||||
) -> Result<String, DomainError>;
|
||||
async fn following_collection_json(
|
||||
&self,
|
||||
user_id: &UserId,
|
||||
page: Option<u32>,
|
||||
) -> Result<String, DomainError>;
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
pub trait FederationFetchPort: Send + Sync {
|
||||
async fn fetch_outbox_page(
|
||||
&self,
|
||||
outbox_url: &str,
|
||||
page: u32,
|
||||
) -> Result<Vec<crate::models::remote_note::RemoteNote>, DomainError>;
|
||||
|
||||
async fn fetch_actor_urls_from_collection(
|
||||
&self,
|
||||
collection_url: &str,
|
||||
) -> Result<Vec<String>, DomainError>;
|
||||
|
||||
async fn resolve_actor_profiles(
|
||||
&self,
|
||||
urls: Vec<String>,
|
||||
) -> Vec<crate::models::actor_connection_summary::ActorConnectionSummary>;
|
||||
}
|
||||
|
||||
pub trait FederationActionPort:
|
||||
FederationLookupPort + FederationFollowPort + FederationFollowRequestPort + FederationFetchPort
|
||||
{
|
||||
}
|
||||
impl<
|
||||
T: FederationLookupPort
|
||||
+ FederationFollowPort
|
||||
+ FederationFollowRequestPort
|
||||
+ FederationFetchPort,
|
||||
> FederationActionPort for T
|
||||
{
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
pub trait FeedRepository: Send + Sync {
|
||||
async fn home_feed(
|
||||
|
||||
@@ -555,11 +555,34 @@ impl RemoteActorRepository for TestStore {
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl FederationActionPort for TestStore {
|
||||
impl FederationLookupPort for TestStore {
|
||||
async fn lookup_actor(&self, _handle: &str) -> Result<RemoteActor, DomainError> {
|
||||
Err(DomainError::NotFound)
|
||||
}
|
||||
|
||||
async fn actor_json(&self, _user_id: &UserId) -> Result<String, DomainError> {
|
||||
Err(DomainError::NotFound)
|
||||
}
|
||||
|
||||
async fn followers_collection_json(
|
||||
&self,
|
||||
_user_id: &UserId,
|
||||
_page: Option<u32>,
|
||||
) -> Result<String, DomainError> {
|
||||
Err(DomainError::NotFound)
|
||||
}
|
||||
|
||||
async fn following_collection_json(
|
||||
&self,
|
||||
_user_id: &UserId,
|
||||
_page: Option<u32>,
|
||||
) -> Result<String, DomainError> {
|
||||
Err(DomainError::NotFound)
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl FederationFollowPort for TestStore {
|
||||
async fn follow_remote(
|
||||
&self,
|
||||
_local_user_id: &UserId,
|
||||
@@ -576,6 +599,16 @@ impl FederationActionPort for TestStore {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn get_remote_following(
|
||||
&self,
|
||||
_user_id: &UserId,
|
||||
) -> Result<Vec<RemoteActor>, DomainError> {
|
||||
Ok(vec![])
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl FederationFollowRequestPort for TestStore {
|
||||
async fn get_pending_followers(
|
||||
&self,
|
||||
_user_id: &UserId,
|
||||
@@ -613,34 +646,10 @@ impl FederationActionPort for TestStore {
|
||||
) -> Result<(), DomainError> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
async fn get_remote_following(
|
||||
&self,
|
||||
_user_id: &UserId,
|
||||
) -> Result<Vec<RemoteActor>, DomainError> {
|
||||
Ok(vec![])
|
||||
}
|
||||
|
||||
async fn actor_json(&self, _user_id: &UserId) -> Result<String, DomainError> {
|
||||
Err(DomainError::NotFound)
|
||||
}
|
||||
|
||||
async fn followers_collection_json(
|
||||
&self,
|
||||
_user_id: &UserId,
|
||||
_page: Option<u32>,
|
||||
) -> Result<String, DomainError> {
|
||||
Err(DomainError::NotFound)
|
||||
}
|
||||
|
||||
async fn following_collection_json(
|
||||
&self,
|
||||
_user_id: &UserId,
|
||||
_page: Option<u32>,
|
||||
) -> Result<String, DomainError> {
|
||||
Err(DomainError::NotFound)
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl FederationFetchPort for TestStore {
|
||||
async fn fetch_outbox_page(
|
||||
&self,
|
||||
_outbox_url: &str,
|
||||
|
||||
Reference in New Issue
Block a user