master
Aevann1 2021-07-26 19:47:52 +02:00
parent 7fcef34c22
commit eaaa153249
8 changed files with 9 additions and 60 deletions

View File

@ -42,7 +42,6 @@ class Comment(Base, Age_times, Scores, Stndrd, Fuzzing):
distinguish_level = Column(Integer, default=0)
deleted_utc = Column(Integer, default=0)
is_approved = Column(Integer, default=0)
approved_utc = Column(Integer, default=0)
level = Column(Integer, default=0)
parent_comment_id = Column(Integer, ForeignKey("comments.id"))

View File

@ -60,7 +60,6 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing):
domain_obj = relationship("Domain")
flags = relationship("Flag", backref="submission")
is_approved = Column(Integer, ForeignKey("users.id"), default=0)
approved_utc = Column(Integer, default=0)
over_18 = Column(Boolean, default=False)
author = relationship(
"User",

View File

@ -2,13 +2,6 @@ from flask import *
import time
from .security import *
def session_over18():
now = int(time.time())
try: return session.get('over_18', 0) >= now
except: return False
def make_logged_out_formkey(t):
s = f"{t}+{session['session_id']}"

View File

@ -728,7 +728,6 @@ def ban_post(post_id, v):
post.is_banned = True
post.is_approved = 0
post.approved_utc = 0
post.stickied = False
post.is_pinned = False
@ -773,7 +772,6 @@ def unban_post(post_id, v):
post.is_banned = False
post.is_approved = v.id
post.approved_utc = int(time.time())
g.db.add(post)
@ -839,7 +837,6 @@ def api_ban_comment(c_id, v):
comment.is_banned = True
comment.is_approved = 0
comment.approved_utc = 0
g.db.add(comment)
ma=ModAction(
@ -870,7 +867,6 @@ def api_unban_comment(c_id, v):
comment.is_banned = False
comment.is_approved = v.id
comment.approved_utc = int(time.time())
return "", 204

View File

@ -85,13 +85,9 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None):
post = get_post(pid, v=v)
if post.over_18 and not (v and v.over_18) and not session_over18():
t = int(time.time())
if post.over_18 and not (v and v.over_18) and not session.get('over_18', 0) >= int(time.time()):
return {'html': lambda: render_template("errors/nsfw.html",
v=v,
t=t,
lo_formkey=make_logged_out_formkey(
t),
),
'api': lambda: {'error': f'This content is not suitable for some users and situations.'}

View File

@ -154,34 +154,14 @@ def error_503(e, v):
}
@app.route("/allow_nsfw_logged_in", methods=["POST"])
@auth_required
@validate_formkey
def allow_nsfw_logged_in(v):
@app.route("/allow_nsfw", methods=["POST"])
def allow_nsfw():
if not session.get("over_18"): session["over_18"] = int(time.time()) + 3600
session["over_18"] = int(time.time()) + 3600
return redirect(request.form.get("redir"))
@app.route("/allow_nsfw_logged_out", methods=["POST"])
@auth_desired
def allow_nsfw_logged_out(v):
if v:
return redirect('/')
t = int(request.form.get('time'))
if not validate_logged_out_formkey(t,
request.form.get("formkey")
):
abort(403)
if not session.get("over_18"): session["over_18"] = int(time.time()) + 3600
return redirect(request.form.get("redir"))
@app.route("/error/<error>", methods=["GET"])
@auth_desired
def error_all_preview(error, v):

View File

@ -232,13 +232,9 @@ def post_base36id(pid, anything=None, v=None):
g.db.add(post)
g.db.commit()
if post.over_18 and not (v and v.over_18) and not session_over18():
t = int(time.time())
if post.over_18 and not (v and v.over_18) and not session.get('over_18', 0) >= int(time.time()):
return {"html":lambda:render_template("errors/nsfw.html",
v=v,
t=t,
lo_formkey=make_logged_out_formkey(t),
),
"api":lambda:(jsonify({"error":"Must be 18+ to view"}), 451)
}

View File

@ -15,20 +15,10 @@
<p class="mb-5">This post is rated +18 (Pornographic Content). You must be 18 or older to continue. Are you sure you want to proceed?</p>
<div class="btn-toolbar justify-content-center mb-4">
{% if v %}
<form action="/allow_nsfw_logged_in" method="post">
<input type="hidden" name="formkey" value="{{v.formkey}}">
<input type="hidden" name="redir" value="{{request.path}}">
<input type="submit" class="btn btn-danger mr-2" value="Yes, I am 18">
</form>
{% else %}
<form action="/allow_nsfw_logged_out" method="post">
<input type="hidden" name="formkey" value="{{lo_formkey}}">
<input type="hidden" name="redir" value="{{request.path}}">
<input type="hidden" name="time" value="{{t}}">
<input type="submit" class="btn btn-danger mr-2" value="Yes, I am 18">
</form>
{% endif %}
<form action="/allow_nsfw" method="post">
<input type="hidden" name="redir" value="{{request.path}}">
<input type="submit" class="btn btn-danger mr-2" value="Yes, I am +18">
</form>
<div><a href="/" class="btn btn-secondary">No</a></div>
</div>