Ignore errors when fetching community mods (fixes #3460) (#3674)

fix_federation_test_errors_1
Nutomic 2023-07-20 17:34:07 +02:00 committed by GitHub
parent 3753a3bf54
commit 1a164a649e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 12 deletions

View File

@ -78,18 +78,20 @@ impl Collection for ApubCommunityModerators {
// Add new mods to database which have been added to moderators collection
for mod_id in apub.ordered_items {
let mod_user: ApubPerson = mod_id.dereference(data).await?;
if !current_moderators
.iter()
.map(|c| c.moderator.actor_id.clone())
.any(|x| x == mod_user.actor_id)
{
let community_moderator_form = CommunityModeratorForm {
community_id: owner.id,
person_id: mod_user.id,
};
CommunityModerator::join(&mut data.pool(), &community_moderator_form).await?;
// Ignore errors as mod accounts might be deleted or instances unavailable.
let mod_user: Option<ApubPerson> = mod_id.dereference(data).await.ok();
if let Some(mod_user) = mod_user {
if !current_moderators
.iter()
.map(|c| c.moderator.actor_id.clone())
.any(|x| x == mod_user.actor_id)
{
let community_moderator_form = CommunityModeratorForm {
community_id: owner.id,
person_id: mod_user.id,
};
CommunityModerator::join(&mut data.pool(), &community_moderator_form).await?;
}
}
}