Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Hide NSFW links from logged in under 18 users.

  • Loading branch information...
commit da9736a8b23b7f176866367094f5888aa5e98bb1 1 parent 8f5ed2a
@bsimpson63 bsimpson63 authored
Showing with 5 additions and 4 deletions.
  1. +5 −4 r2/r2/models/link.py
View
9 r2/r2/models/link.py
@@ -225,15 +225,16 @@ def keep_item(self, wrapped):
if wrapped.hidden:
return False
- # hide NSFW links from non-logged users if they're not explicitly
- # visiting an NSFW subreddit
- if not c.user_is_loggedin and c.site != wrapped.subreddit:
+ # hide NSFW links from non-logged users and under 18 logged users
+ # if they're not explicitly visiting an NSFW subreddit
+ if ((not c.user_is_loggedin and c.site != wrapped.subreddit)
+ or (c.user_is_loggedin and not c.over18)):
is_nsfw = bool(wrapped.over_18)
is_from_nsfw_sr = bool(wrapped.subreddit.over_18)
if is_nsfw or is_from_nsfw_sr:
return False
-
+
return True
# none of these things will change over a link's lifetime
Please sign in to comment.
Something went wrong with that request. Please try again.