mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-04-05 03:00:15 -04:00
Don't filter NSFW listings when using the API.
This commit is contained in:
@@ -18,6 +18,8 @@ extension_mapping = {
|
||||
"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]
|
||||
|
||||
@@ -27,7 +27,7 @@ from r2.lib.utils.trial_utils import trial_info
|
||||
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 @@ class Link(Thing, Printable):
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user