Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetch community outbox and moderators in parallel #3360

Merged
merged 1 commit into from
Jun 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions crates/apub/src/objects/community.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,19 +140,16 @@ impl Object for ApubCommunity {

// Fetching mods and outbox is not necessary for Lemmy to work, so ignore errors. Besides,
// we need to ignore these errors so that tests can work entirely offline.
group
.outbox
.dereference(&community, context)
.await
.map_err(|e| debug!("{}", e))
.ok();
let fetch_outbox = group.outbox.dereference(&community, context);

if let Some(moderators) = group.attributed_to {
moderators
.dereference(&community, context)
.await
.map_err(|e| debug!("{}", e))
.ok();
let fetch_moderators = moderators.dereference(&community, context);
// Fetch mods and outbox in parallel
let res = tokio::join!(fetch_outbox, fetch_moderators);
res.0.map_err(|e| debug!("{}", e)).ok();
res.1.map_err(|e| debug!("{}", e)).ok();
} else {
fetch_outbox.await.map_err(|e| debug!("{}", e)).ok();
}

Ok(community)
Expand Down