Permalink
Browse files

simplify link.py NSFW filter condition

based on spladug comment
  • Loading branch information...
1 parent e737535 commit 615abf2508971cc97bb6fc41df3e9dddfda57de4 @talklittle committed Jul 15, 2012
Showing with 5 additions and 11 deletions.
  1. +5 −11 r2/r2/models/link.py
View
@@ -225,17 +225,11 @@ def keep_item(self, wrapped):
if is_api and not c.obey_over18:
return True
- # hide NSFW links from non-logged users and under 18 logged users
- # if they're not explicitly visiting an NSFW subreddit or a multireddit
- 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
+ # hide NSFW links from users unless they have the over18 cookie
+ item_is_over18 = bool(wrapped.over18) or bool(wrapped.subreddit.over18)
+ user_is_over18 = (c.over18)
+ if item_is_over18 and not user_is_over18:
+ return False
return True

0 comments on commit 615abf2

Please sign in to comment.