Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Don't filter NSFW reddits for API clients #526

Closed
wants to merge 3 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion r2/r2/controllers/listingcontroller.py
Expand Up @@ -26,6 +26,7 @@

from r2.models import *
from r2.models.query_cache import CachedQuery, MergedCachedQuery
from r2.config import extensions
from r2.config.extensions import is_api
from r2.lib.pages import *
from r2.lib.pages.things import wrap_links
Expand Down Expand Up @@ -922,7 +923,9 @@ def query(self):
# don't try to render special subreddits (like promos)
reddits._filter(Subreddit.c.author_id != -1)

if not c.over18:
# Always show NSFW to API users unless obey_over18=true in querystring
is_api_client = c.render_style in extensions.API_TYPES
if (not is_api_client and not c.over18) or (is_api_client and c.obey_over18):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In its current form, this appears to always filter out over18 if c.obey_over18 even if c.over18. Instead, it should probably read:

    if not c.over18 and (not is_api_client or c.obey_over18):

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I guess it should actually test the thing that it's supposed to be obeying. Yours looks correct, I'll update it.

reddits._filter(Subreddit.c.over_18 == False)

if self.where == 'popular':
Expand Down