From 1a164a649e187d32185458fc2d5ab08515320880 Mon Sep 17 00:00:00 2001 From: Nutomic Date: Thu, 20 Jul 2023 17:34:07 +0200 Subject: [PATCH] Ignore errors when fetching community mods (fixes #3460) (#3674) --- .../src/collections/community_moderators.rs | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) 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 = 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?; + } } } -- 2.44.1