From d83f96293de8611cad7e1388c62594cdc13820f0 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Thu, 9 Jan 2025 04:02:44 -0500 Subject: [PATCH] Automatically marking posts created in an NSFW community as NSFW. (#5310) * Automatically marking posts created in an NSFW community as NSFW. - Context: https://github.com/LemmyNet/lemmy-ui/issues/2885 * Update crates/api_crud/src/post/create.rs Co-authored-by: Nutomic --------- Co-authored-by: Nutomic --- crates/api_crud/src/post/create.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/api_crud/src/post/create.rs b/crates/api_crud/src/post/create.rs index 452144faa..e9e11bc16 100644 --- a/crates/api_crud/src/post/create.rs +++ b/crates/api_crud/src/post/create.rs @@ -86,6 +86,9 @@ pub async fn create_post( let community = Community::read(&mut context.pool(), data.community_id).await?; check_community_user_action(&local_user_view.person, &community, &mut context.pool()).await?; + // If its an NSFW community, then use that as a default + let nsfw = data.nsfw.or(Some(community.nsfw)); + if community.posting_restricted_to_mods { let community_id = data.community_id; CommunityModeratorView::check_is_community_moderator( @@ -110,7 +113,7 @@ pub async fn create_post( url, body, alt_text: data.alt_text.clone(), - nsfw: data.nsfw, + nsfw, language_id: Some(language_id), scheduled_publish_time, ..PostInsertForm::new(