feat(activitypub-base): implement federation management port methods
This commit is contained in:
@@ -1140,6 +1140,28 @@ impl ActivityPubService {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn adapter_actor_to_domain(
|
||||||
|
a: crate::repository::RemoteActor,
|
||||||
|
) -> domain::models::remote_actor::RemoteActor {
|
||||||
|
domain::models::remote_actor::RemoteActor {
|
||||||
|
url: a.url,
|
||||||
|
handle: a.handle,
|
||||||
|
display_name: a.display_name,
|
||||||
|
inbox_url: a.inbox_url,
|
||||||
|
shared_inbox_url: a.shared_inbox_url,
|
||||||
|
avatar_url: a.avatar_url,
|
||||||
|
outbox_url: a.outbox_url,
|
||||||
|
public_key: String::new(),
|
||||||
|
last_fetched_at: chrono::Utc::now(),
|
||||||
|
bio: None,
|
||||||
|
banner_url: None,
|
||||||
|
also_known_as: None,
|
||||||
|
followers_url: None,
|
||||||
|
following_url: None,
|
||||||
|
attachment: vec![],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn spawn_backfill(&self, owner_user_id: uuid::Uuid, follower_inbox_url: String) {
|
fn spawn_backfill(&self, owner_user_id: uuid::Uuid, follower_inbox_url: String) {
|
||||||
let config = self.federation_config.clone();
|
let config = self.federation_config.clone();
|
||||||
let base_url = self.base_url.clone();
|
let base_url = self.base_url.clone();
|
||||||
@@ -1772,47 +1794,62 @@ impl domain::ports::FederationActionPort for ActivityPubService {
|
|||||||
|
|
||||||
async fn get_pending_followers(
|
async fn get_pending_followers(
|
||||||
&self,
|
&self,
|
||||||
_user_id: &domain::value_objects::UserId,
|
user_id: &domain::value_objects::UserId,
|
||||||
) -> Result<Vec<domain::models::remote_actor::RemoteActor>, domain::errors::DomainError> {
|
) -> Result<Vec<domain::models::remote_actor::RemoteActor>, domain::errors::DomainError> {
|
||||||
Ok(vec![])
|
self.get_pending_followers(user_id.as_uuid())
|
||||||
|
.await
|
||||||
|
.map(|v| v.into_iter().map(Self::adapter_actor_to_domain).collect())
|
||||||
|
.map_err(|e| domain::errors::DomainError::ExternalService(e.to_string()))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn accept_follow_request(
|
async fn accept_follow_request(
|
||||||
&self,
|
&self,
|
||||||
_user_id: &domain::value_objects::UserId,
|
user_id: &domain::value_objects::UserId,
|
||||||
_actor_url: &str,
|
actor_url: &str,
|
||||||
) -> Result<(), domain::errors::DomainError> {
|
) -> Result<(), domain::errors::DomainError> {
|
||||||
Ok(())
|
self.accept_follower(user_id.as_uuid(), actor_url)
|
||||||
|
.await
|
||||||
|
.map_err(|e| domain::errors::DomainError::ExternalService(e.to_string()))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn reject_follow_request(
|
async fn reject_follow_request(
|
||||||
&self,
|
&self,
|
||||||
_user_id: &domain::value_objects::UserId,
|
user_id: &domain::value_objects::UserId,
|
||||||
_actor_url: &str,
|
actor_url: &str,
|
||||||
) -> Result<(), domain::errors::DomainError> {
|
) -> Result<(), domain::errors::DomainError> {
|
||||||
Ok(())
|
self.reject_follower(user_id.as_uuid(), actor_url)
|
||||||
|
.await
|
||||||
|
.map_err(|e| domain::errors::DomainError::ExternalService(e.to_string()))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_remote_followers(
|
async fn get_remote_followers(
|
||||||
&self,
|
&self,
|
||||||
_user_id: &domain::value_objects::UserId,
|
user_id: &domain::value_objects::UserId,
|
||||||
) -> Result<Vec<domain::models::remote_actor::RemoteActor>, domain::errors::DomainError> {
|
) -> Result<Vec<domain::models::remote_actor::RemoteActor>, domain::errors::DomainError> {
|
||||||
Ok(vec![])
|
self.get_accepted_followers(user_id.as_uuid())
|
||||||
|
.await
|
||||||
|
.map(|v| v.into_iter().map(Self::adapter_actor_to_domain).collect())
|
||||||
|
.map_err(|e| domain::errors::DomainError::ExternalService(e.to_string()))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn remove_remote_follower(
|
async fn remove_remote_follower(
|
||||||
&self,
|
&self,
|
||||||
_user_id: &domain::value_objects::UserId,
|
user_id: &domain::value_objects::UserId,
|
||||||
_actor_url: &str,
|
actor_url: &str,
|
||||||
) -> Result<(), domain::errors::DomainError> {
|
) -> Result<(), domain::errors::DomainError> {
|
||||||
Ok(())
|
self.remove_follower(user_id.as_uuid(), actor_url)
|
||||||
|
.await
|
||||||
|
.map_err(|e| domain::errors::DomainError::ExternalService(e.to_string()))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_remote_following(
|
async fn get_remote_following(
|
||||||
&self,
|
&self,
|
||||||
_user_id: &domain::value_objects::UserId,
|
user_id: &domain::value_objects::UserId,
|
||||||
) -> Result<Vec<domain::models::remote_actor::RemoteActor>, domain::errors::DomainError> {
|
) -> Result<Vec<domain::models::remote_actor::RemoteActor>, domain::errors::DomainError> {
|
||||||
Ok(vec![])
|
self.get_following(user_id.as_uuid())
|
||||||
|
.await
|
||||||
|
.map(|v| v.into_iter().map(Self::adapter_actor_to_domain).collect())
|
||||||
|
.map_err(|e| domain::errors::DomainError::ExternalService(e.to_string()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user