master
Aevann1 2022-04-18 19:51:39 +02:00
parent 8d268268f1
commit 521eb16db7
2 changed files with 6 additions and 6 deletions

View File

@ -93,10 +93,10 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None, sub=None):
except: abort(404) except: abort(404)
post = get_post(pid, v=v) post = get_post(pid, v=v)
if post.over_18 and not (v and v.over_18) and not session.get('over_18', 0) >= int(time.time()): if post.over_18 and not (v and v.over_18) and not session.get('over_18', 0) >= int(time.time()):
if request.headers.get("Authorization"): return {'error': 'This content is not suitable for some users and situations.'} if request.headers.get("Authorization"): return {'error': 'This content is not suitable for some users and situations.'}
else: render_template("errors/nsfw.html", v=v) else: return render_template("errors/nsfw.html", v=v)
try: context = min(int(request.values.get("context", 0)), 8) try: context = min(int(request.values.get("context", 0)), 8)
except: context = 0 except: context = 0

View File

@ -129,6 +129,10 @@ def post_id(pid, anything=None, v=None, sub=None):
post = get_post(pid, v=v) post = get_post(pid, v=v)
if post.over_18 and not (v and v.over_18) and session.get('over_18', 0) < int(time.time()):
if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error":"Must be 18+ to view"}, 451
return render_template("errors/nsfw.html", v=v)
if post.new or 'megathread' in post.title.lower(): defaultsortingcomments = 'new' if post.new or 'megathread' in post.title.lower(): defaultsortingcomments = 'new'
elif v: defaultsortingcomments = v.defaultsortingcomments elif v: defaultsortingcomments = v.defaultsortingcomments
else: defaultsortingcomments = "top" else: defaultsortingcomments = "top"
@ -247,10 +251,6 @@ def post_id(pid, anything=None, v=None, sub=None):
post.views += 1 post.views += 1
g.db.add(post) g.db.add(post)
if post.over_18 and not (v and v.over_18) and session.get('over_18', 0) < int(time.time()):
if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error":"Must be 18+ to view"}, 451
return render_template("errors/nsfw.html", v=v)
g.db.commit() g.db.commit()
if request.headers.get("Authorization"): return post.json if request.headers.get("Authorization"): return post.json
else: else: