This repository has been archived by the owner. It is now read-only.

Don't filter NSFW listings when using the API. #402

Closed
wants to merge 1 commit into
from
Jump to file or symbol
Failed to load files and symbols.
+7 −1
Diff settings

Always

Just for now

@@ -18,6 +18,8 @@
"i": ("compact", "text/html; charset=UTF-8"),
}
+API_TYPES = ('api', 'json')
+
def set_extension(environ, ext):
environ["extension"] = ext
environ["render_style"], environ["content_type"] = extension_mapping[ext]
View
@@ -27,7 +27,7 @@
from account import Account, DeletedUser
from subreddit import Subreddit
from printable import Printable
-from r2.config import cache
+from r2.config import cache, extensions
from r2.lib.memoize import memoize
from r2.lib.filters import _force_utf8
from r2.lib import utils
@@ -217,6 +217,10 @@ def keep_item(self, wrapped):
if wrapped.hidden:
return False
+ # Don't hide from API users
+ if c.render_style in extensions.API_TYPES:
+ 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
if (((not c.user_is_loggedin and c.site != wrapped.subreddit)