refactor(domain): remove FetchRemoteActorPosts/FetchActorConnections from DomainEvent; add FederationSchedulerPort
This commit is contained in:
@@ -1,14 +1,13 @@
|
||||
use domain::{
|
||||
errors::DomainError,
|
||||
events::DomainEvent,
|
||||
models::{
|
||||
actor_connection_summary::ActorConnectionSummary,
|
||||
feed::{FeedEntry, PageParams, Paginated},
|
||||
remote_actor::RemoteActor,
|
||||
},
|
||||
ports::{
|
||||
ActivityPubRepository, EventPublisher, FederationActionPort, FeedRepository,
|
||||
FollowRepository, RemoteActorConnectionRepository, UserRepository,
|
||||
ActivityPubRepository, EventPublisher, FederationActionPort, FederationSchedulerPort,
|
||||
FeedRepository, FollowRepository, RemoteActorConnectionRepository, UserRepository,
|
||||
},
|
||||
value_objects::UserId,
|
||||
};
|
||||
@@ -75,7 +74,7 @@ pub async fn get_remote_actor_posts(
|
||||
federation: &dyn FederationActionPort,
|
||||
ap_repo: &dyn ActivityPubRepository,
|
||||
feed: &dyn FeedRepository,
|
||||
events: &dyn EventPublisher,
|
||||
scheduler: &dyn FederationSchedulerPort,
|
||||
handle: &str,
|
||||
page: PageParams,
|
||||
viewer_id: Option<&UserId>,
|
||||
@@ -88,11 +87,8 @@ pub async fn get_remote_actor_posts(
|
||||
};
|
||||
let result = feed.user_feed(&author_id, &page, viewer_id).await?;
|
||||
if let Some(outbox_url) = actor.outbox_url {
|
||||
let _ = events
|
||||
.publish(&DomainEvent::FetchRemoteActorPosts {
|
||||
actor_ap_url: actor.url,
|
||||
outbox_url,
|
||||
})
|
||||
let _ = scheduler
|
||||
.schedule_actor_posts_fetch(&actor.url, &outbox_url)
|
||||
.await;
|
||||
}
|
||||
Ok(result)
|
||||
@@ -103,7 +99,7 @@ const ACTOR_CONNECTIONS_CACHE_TTL_SECS: i64 = 3600;
|
||||
pub async fn get_actor_connections_page(
|
||||
federation: &dyn FederationActionPort,
|
||||
connections: &dyn RemoteActorConnectionRepository,
|
||||
events: &dyn EventPublisher,
|
||||
scheduler: &dyn FederationSchedulerPort,
|
||||
handle: &str,
|
||||
connection_type: &str,
|
||||
page: u32,
|
||||
@@ -128,13 +124,8 @@ pub async fn get_actor_connections_page(
|
||||
}
|
||||
};
|
||||
if stale {
|
||||
let _ = events
|
||||
.publish(&DomainEvent::FetchActorConnections {
|
||||
actor_ap_url: actor.url,
|
||||
collection_url,
|
||||
connection_type: connection_type.to_string(),
|
||||
page,
|
||||
})
|
||||
let _ = scheduler
|
||||
.schedule_connections_fetch(&actor.url, &collection_url, connection_type, page)
|
||||
.await;
|
||||
}
|
||||
let has_more = items.len() >= PAGE_SIZE;
|
||||
|
||||
Reference in New Issue
Block a user