fix: fetch_actor_urls_from_collection follows 'first' page link like outbox does
Some checks failed
lint / lint (push) Has been cancelled
test / unit (push) Has been cancelled
test / integration (push) Has been cancelled
lint / lint (pull_request) Has been cancelled
test / unit (pull_request) Has been cancelled
test / integration (pull_request) Has been cancelled

This commit is contained in:
2026-05-15 01:18:28 +02:00
parent e3251b6928
commit 27e94d64b0

View File

@@ -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()))