From: Nutomic <me@nutomic.com> Date: Thu, 20 Jul 2023 15:34:07 +0000 (+0200) Subject: Ignore errors when fetching community mods (fixes #3460) (#3674) X-Git-Url: http://these/git/%7B%60%24%7BarchiveTodayUrl%7D/%22https:/hacktivis.me/%22?a=commitdiff_plain;h=1a164a649e187d32185458fc2d5ab08515320880;p=lemmy.git Ignore errors when fetching community mods (fixes #3460) (#3674) --- diff --git a/crates/apub/src/collections/community_moderators.rs b/crates/apub/src/collections/community_moderators.rs index 17265e2d..cdaf985e 100644 --- a/crates/apub/src/collections/community_moderators.rs +++ b/crates/apub/src/collections/community_moderators.rs @@ -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?; + } } }