Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix NSFW behavior for non-logged-in clients

specifically when visiting non-nsfw subreddits
it was showing NSFW links
  • Loading branch information...
commit e7375354f88b58fc75dbf483d43395547f4da294 1 parent 9cd5fed
@talklittle authored
Showing with 7 additions and 6 deletions.
  1. +7 −6 r2/r2/models/link.py
View
13 r2/r2/models/link.py
@@ -227,12 +227,13 @@ def keep_item(self, wrapped):
# hide NSFW links from non-logged users and under 18 logged users
# if they're not explicitly visiting an NSFW subreddit or a multireddit
- if (((not c.user_is_loggedin and c.site != wrapped.subreddit)
- or (c.user_is_loggedin and not c.over18))
- and not (isinstance(c.site, MultiReddit) and c.over18)):
- is_nsfw = bool(wrapped.over_18)
- is_from_nsfw_sr = bool(wrapped.subreddit.over_18)
-
+ is_nsfw = bool(wrapped.over_18)
+ is_from_nsfw_sr = bool(wrapped.subreddit.over_18)
+ is_visiting_nsfw_sr = is_from_nsfw_sr and c.site == wrapped.subreddit
+ is_loggedout_visiting_under18_sr = not c.user_is_loggedin and not is_visiting_nsfw_sr
+ is_loggedin_under18 = c.user_is_loggedin and not c.over18
+ is_multireddit = isinstance(c.site, MultiReddit)
+ if ((is_loggedout_visiting_under18_sr or is_loggedin_under18) and not (is_multireddit and c.over18)):
if is_nsfw or is_from_nsfw_sr:
return False
Please sign in to comment.
Something went wrong with that request. Please try again.