feat: v2 rewrite — hexagonal arch, ActivityPub federation, NATS, deployment-ready #1
@@ -1622,7 +1622,8 @@ impl domain::ports::FederationActionPort for ActivityPubService {
|
||||
&self,
|
||||
collection_url: &str,
|
||||
) -> Result<Vec<String>, domain::errors::DomainError> {
|
||||
let resp: serde_json::Value = reqwest::Client::new()
|
||||
let client = reqwest::Client::new();
|
||||
let base: serde_json::Value = client
|
||||
.get(collection_url)
|
||||
.header("Accept", "application/activity+json, application/ld+json")
|
||||
.send()
|
||||
@@ -1632,8 +1633,27 @@ impl domain::ports::FederationActionPort for ActivityPubService {
|
||||
.await
|
||||
.map_err(|e| domain::errors::DomainError::ExternalService(e.to_string()))?;
|
||||
|
||||
// Base collections typically have no orderedItems — follow the `first` page link.
|
||||
let page = if base["orderedItems"].is_null() {
|
||||
if let Some(first_url) = base["first"].as_str() {
|
||||
client
|
||||
.get(first_url)
|
||||
.header("Accept", "application/activity+json, application/ld+json")
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| domain::errors::DomainError::ExternalService(e.to_string()))?
|
||||
.json()
|
||||
.await
|
||||
.map_err(|e| domain::errors::DomainError::ExternalService(e.to_string()))?
|
||||
} else {
|
||||
base
|
||||
}
|
||||
} else {
|
||||
base
|
||||
};
|
||||
|
||||
let empty = vec![];
|
||||
let items = resp["orderedItems"].as_array().unwrap_or(&empty);
|
||||
let items = page["orderedItems"].as_array().unwrap_or(&empty);
|
||||
Ok(items
|
||||
.iter()
|
||||
.filter_map(|v| v.as_str().map(|s| s.to_string()))
|
||||
|
||||
Reference in New Issue
Block a user