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 <me@nutomic.com>

---------

Co-authored-by: Nutomic <me@nutomic.com>
This commit is contained in:
Dessalines 2025-01-09 04:02:44 -05:00 committed by GitHub
parent c81144cd14
commit d83f96293d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -86,6 +86,9 @@ pub async fn create_post(
let community = Community::read(&mut context.pool(), data.community_id).await?; let community = Community::read(&mut context.pool(), data.community_id).await?;
check_community_user_action(&local_user_view.person, &community, &mut context.pool()).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 { if community.posting_restricted_to_mods {
let community_id = data.community_id; let community_id = data.community_id;
CommunityModeratorView::check_is_community_moderator( CommunityModeratorView::check_is_community_moderator(
@ -110,7 +113,7 @@ pub async fn create_post(
url, url,
body, body,
alt_text: data.alt_text.clone(), alt_text: data.alt_text.clone(),
nsfw: data.nsfw, nsfw,
language_id: Some(language_id), language_id: Some(language_id),
scheduled_publish_time, scheduled_publish_time,
..PostInsertForm::new( ..PostInsertForm::new(