Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Don't filter NSFW reddits for API clients #526

Closed
wants to merge 3 commits into from

3 participants

@Deimos
Owner

No description provided.

@bboe

How does this pull request interact with #479?

@Deimos
Owner

I don't think there should be any crossover, this is specifically for the subreddit-listing page (/reddits), whereas #479 seems to be related to listings of actual submissions inside subreddits.

r2/r2/controllers/listingcontroller.py
@@ -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):
@spladug Owner
spladug added a note

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):
@Deimos Owner
Deimos added a note

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@spladug
Owner

Due to fixing the bad query, this will no longer work as-is. I'm going to close this pull request. If you'd like to implement this functionality (which sounds good to me) in the keep_fn I'll gladly take a new request. Thanks for all your work on this.

@spladug spladug closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 12, 2012
  1. @Deimos
Commits on Sep 13, 2012
  1. @Deimos
Commits on Oct 1, 2012
  1. @Deimos

    Actually obey over18

    Deimos authored
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 1 deletion.
  1. +4 −1 r2/r2/controllers/listingcontroller.py
View
5 r2/r2/controllers/listingcontroller.py
@@ -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
@@ -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 c.over18 and (not is_api_client or c.obey_over18):
reddits._filter(Subreddit.c.over_18 == False)
if self.where == 'popular':
Something went wrong with that request. Please try again.