]> Untitled Git - lemmy.git/commitdiff
Ignore errors when fetching community mods (fixes #3460) (#3674)
authorNutomic <me@nutomic.com>
Thu, 20 Jul 2023 15:34:07 +0000 (17:34 +0200)
committerGitHub <noreply@github.com>
Thu, 20 Jul 2023 15:34:07 +0000 (11:34 -0400)
crates/apub/src/collections/community_moderators.rs

index 17265e2d63ea41620308408d563f2510954ecaa0..cdaf985ea64b31432fd4a121dfd5a218e7183af1 100644 (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?;
+        }
       }
     }