diff --git a/crates/apub/src/objects/community.rs b/crates/apub/src/objects/community.rs index 689641910..25ff7a91f 100644 --- a/crates/apub/src/objects/community.rs +++ b/crates/apub/src/objects/community.rs @@ -193,16 +193,10 @@ impl Object for ApubCommunity { LanguageTag::to_language_id_multiple(group.language, &mut context.pool()).await?; let timestamp = group.updated.or(group.published).unwrap_or_else(Utc::now); - let community: ApubCommunity = Community::insert_apub(&mut context.pool(), timestamp, &form) - .await? - .into(); + let community = Community::insert_apub(&mut context.pool(), timestamp, &form).await?; CommunityLanguage::update(&mut context.pool(), languages, community.id).await?; - // Need to fetch mods synchronously, otherwise fetching a post in community with - // `posting_restricted_to_mods` can fail if mods havent been fetched yet. - if let Some(moderators) = group.attributed_to { - moderators.dereference(&community, context).await.ok(); - } + let community: ApubCommunity = community.into(); // These collections are not necessary for Lemmy to work, so ignore errors. let community_ = community.clone(); @@ -215,6 +209,9 @@ impl Object for ApubCommunity { if let Some(featured) = group.featured { featured.dereference(&community_, &context_).await.ok(); } + if let Some(moderators) = group.attributed_to { + moderators.dereference(&community_, &context_).await.ok(); + } Ok(()) }); diff --git a/crates/apub/src/objects/post.rs b/crates/apub/src/objects/post.rs index 64effbe6a..73d937ad5 100644 --- a/crates/apub/src/objects/post.rs +++ b/crates/apub/src/objects/post.rs @@ -177,7 +177,11 @@ impl Object for ApubPost { async fn from_json(page: Page, context: &Data) -> LemmyResult { let creator = page.creator()?.dereference(context).await?; let community = page.community(context).await?; - if community.posting_restricted_to_mods { + + // Prevent posts from non-mod users in local, restricted community. If its a remote community + // then its possible that the restricted setting was enabled recently, so existing user posts + // should still be fetched. + if community.local && community.posting_restricted_to_mods { CommunityModeratorView::check_is_community_moderator( &mut context.pool(), community.id,