feat(activitypub-base): impl FederationActionPort for ActivityPubService
This commit is contained in:
@@ -1330,6 +1330,42 @@ impl domain::ports::OutboundFederationPort for ActivityPubService {
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl domain::ports::FederationActionPort for ActivityPubService {
|
||||
async fn lookup_actor(
|
||||
&self,
|
||||
handle: &str,
|
||||
) -> Result<domain::models::remote_actor::RemoteActor, domain::errors::DomainError> {
|
||||
let data = self.federation_config.to_request_data();
|
||||
let actor: crate::actors::DbActor =
|
||||
webfinger_resolve_actor(handle, &data)
|
||||
.await
|
||||
.map_err(|e: crate::error::Error| {
|
||||
domain::errors::DomainError::ExternalService(e.to_string())
|
||||
})?;
|
||||
Ok(domain::models::remote_actor::RemoteActor {
|
||||
url: actor.ap_id.to_string(),
|
||||
handle: actor.username.clone(),
|
||||
display_name: actor.bio.clone(),
|
||||
inbox_url: actor.inbox_url.to_string(),
|
||||
shared_inbox_url: None,
|
||||
public_key: actor.public_key_pem.clone(),
|
||||
avatar_url: actor.avatar_url.as_ref().map(|u| u.to_string()),
|
||||
last_fetched_at: actor.last_refreshed_at,
|
||||
})
|
||||
}
|
||||
|
||||
async fn follow_remote(
|
||||
&self,
|
||||
local_user_id: &domain::value_objects::UserId,
|
||||
handle: &str,
|
||||
) -> Result<(), domain::errors::DomainError> {
|
||||
self.follow(local_user_id.as_uuid(), handle)
|
||||
.await
|
||||
.map_err(|e| domain::errors::DomainError::ExternalService(e.to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "tests/service.rs"]
|
||||
mod tests;
|
||||
|
||||
Reference in New Issue
Block a user