mirror of
https://github.com/LemmyNet/lemmy.git
synced 2025-02-02 23:31:41 +00:00
Change federation community restricted check to apply only locally (#5343)
* Revert "Fetch community mods synchronously (#5169)"
This reverts commit 542e59bcae
.
* change restricted check (fixes #5337)
This commit is contained in:
parent
af71cc55ab
commit
72b74679aa
2 changed files with 10 additions and 9 deletions
|
@ -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(())
|
||||
});
|
||||
|
||||
|
|
|
@ -177,7 +177,11 @@ impl Object for ApubPost {
|
|||
async fn from_json(page: Page, context: &Data<Self::DataType>) -> LemmyResult<ApubPost> {
|
||||
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,
|
||||
|
|
Loading…
Reference in a new issue