-
-
Notifications
You must be signed in to change notification settings - Fork 902
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new setting to block NSFW content #5436
base: main
Are you sure you want to change the base?
Add new setting to block NSFW content #5436
Conversation
Not sure if this makes sense, is there any issue where it was discussed? At least it should be possible to make nsfw posts in remote communities which allow nsfw content. |
Sorry, I should've added more context. This was prompted from the feddit.uk admin chat where we've been discussing how we handle our obligations under the Online Safety Act and one of the big things it tries to tackle is children accessing pornography. Basically, we're liable to face a big fine if we allow users to access adult content without first verifying that they're adults. Instead of trying to do age verification, we'd prefer not to host adult content in the first place (host in this case includes posts made by non-local users).
I can't imagine an admin only being OK hosting adult content if it's in a non-local community. |
Ah with that explanation it makes sense. However there are probably many instances which dont want to be so strict, so this behaviour should be a separate setting. |
Agree, the content_warning.is_some() means your entire site is nsfw. If its So we probably need a separate boolean column in |
"postgres", | ||
"serde_json", | ||
"uuid", | ||
"64-column-tables", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Figured this would be OK given it's already happening in #5407
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep that's fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx, this looks really good, and a lot of instances will probably use this.
Up to @Nutomic as to whether to merge this before or after the large aggregates-removal PR.
crates/apub/src/objects/community.rs
Outdated
|
||
// If NSFW is not allowed, reject new communities marked NSFW and | ||
// remove communities that update to be NSFW | ||
let nsfw_disallowed = local_site.is_some_and(|s| s.disallow_nsfw_content); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to use the same function you created. You might need to make local_site
into an &Option<LocalSite>
, like I'm seeing a few of the other functions in api_common/utils
Side point but @Nutomic I'm seeing this let local_site_data = local_site_data_cached(&mut context.pool()).await?
in some places, and other places it runs LocalSite::read(...
Might be good to make an issue about going over all those in the apub code, and making them all use the cached version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LocalSite::read is also cached so thats fine. However I found that slur filter handling is unnecessarily complicated, opened #5442 for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW @flamingo-cant-draw would you be able to help become a lemmy maintainer? It'd be a huge help.
If so, link me your matrix id so we can add you to a maintainers chat, and I'll get you added as a maintainer on github also.
crates/apub/src/objects/community.rs
Outdated
let block_for_nsfw = check_nsfw_allowed(group.sensitive, local_site.as_ref()); | ||
let removed = if let Err(e) = block_for_nsfw { | ||
let c = ApubCommunity::read_from_id(group.id.inner().clone(), context).await?; | ||
if c.is_some() { | ||
Some(true) | ||
} else { | ||
Err(e)? | ||
} | ||
} else { | ||
None | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I doubt you need to read the community. Probably this is enough.
// Your previous comment
let removed = check_nsfw_allowed(group.sensitive, local_site.as_ref()).is_err();
crates/apub/src/objects/post.rs
Outdated
// posts that get updated to be NSFW | ||
let block_for_nsfw = check_nsfw_allowed(page.sensitive, local_site.as_ref()); | ||
if block_for_nsfw.is_err() { | ||
let post = ApubPost::read_from_id(page.id.inner().clone(), context).await?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same, I don't think you need to read the post, you already have the url above for purging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. I did this to see if the post already existed, but thinking about it I could just ignore NotFound
errors from ApubPost::delete
to avoid the extra db query.
@dessalines Sure, I'd love to help! My matrix username is |
Sweet, I'll get you added shortly. |
crates/apub/src/objects/community.rs
Outdated
// If NSFW is not allowed, then remove NSFW communities | ||
let removed = check_nsfw_allowed(group.sensitive, local_site.as_ref()) | ||
.map_err(|_err| true) | ||
.err(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should just be able to use .is_err()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm trying to limit this to be either Some(true)
or None
to avoid unintentionally unremoving a community.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hrm. There's probably a .err_and_then .
If not, just use |_|
on L157
Block NSFW posts or communities from being created via either the API or federation.
Depends on LemmyNet/lemmy-js-client#500