remotes/1693045480750635534/spooky-22
Aevann1 2021-07-22 21:09:12 +02:00
parent c3eed6df6a
commit 653230b944
5 changed files with 16 additions and 14 deletions

View File

@ -24,14 +24,13 @@ beams_client = PushNotifications(
@app.route("/banaward/comment/<comment_id>", methods=["POST"])
@auth_required
def banawardcomment(comment_id, v):
if v.banawards != 1 and v.banawards != 2: return "You must have a ban award to ban this user. You can obtain it here:\nhttps://rdrama.gumroad.com/l/tfcvri\nhttps://www.patreon.com/Aevann"
if v.banawards != 1 and v.banawards != 2: return jsonify({"error": "You must have a ban award to ban this user."}), 403
comment = g.db.query(Comment).filter_by(id=comment_id).first()
if not comment: abort(400)
u = comment.author
if u.admin_level > 0: abort(403)
if u.admin_level > 0: return jsonify({"error": "You can't ban admins."}), 403
u.ban(admin=v, reason="1 day ban award", days=1)
send_notification(1046, u, f"Your Drama account has been suspended for 1 day for the following reason:\n\n> 1 day ban award")
@ -51,7 +50,8 @@ def banawardcomment(comment_id, v):
comment.banaward = v.username
g.db.add(comment)
return "", 204
return jsonify({"message": "User banned successfully!"}), 200
@app.route("/api/v1/post/<pid>/comment/<cid>", methods=["GET"])
def comment_cid_api_redirect(cid=None, pid=None):

View File

@ -36,12 +36,12 @@ with open("snappy.txt", "r") as f:
@auth_required
def postbanaward(post_id, v):
if v.banawards != 1 and v.banawards != 2: return "You must have a ban award to ban this user. You can obtain it here:\nhttps://rdrama.gumroad.com/l/tfcvri\nhttps://www.patreon.com/Aevann"
if v.banawards != 1 and v.banawards != 2: return jsonify({"error": "You must have a ban award to ban this user."}), 403
post = g.db.query(Submission).filter_by(id=post_id).first()
if not post: abort(400)
u = post.author
if u.admin_level > 0: abort(403)
if u.admin_level > 0: return jsonify({"error": "You can't ban admins."}), 403
u.ban(admin=v, reason="1 day ban award", days=1)
send_notification(1046, u, f"Your Drama account has been suspended for 1 day for the following reason:\n\n> 1 day ban award")
@ -61,7 +61,7 @@ def postbanaward(post_id, v):
post.banaward = v.username
g.db.add(post)
return "", 204
return jsonify({"message": "User banned successfully!"}), 200
@app.route("/api/publish/<pid>", methods=["POST"])
@is_not_banned

View File

@ -243,7 +243,7 @@
<li class="list-inline-item text-muted d-none d-md-inline-block"><a href="/votes?link=https://rdrama.net{{c.permalink}}"><i class="fas fa-arrows-v"></i>Votes</a></li>
{% if v and v.id!=p.author_id %}
<li class="list-inline-item text-muted d-none d-md-inline-block"><a href="javascript:void(0)" onclick="post('/banaward/comment/{{c.id}}', function(){window.location.reload(true);})"><i class="fas fa-user-slash text-danger"></i>Ban user</a></li>
<li class="list-inline-item text-muted d-none d-md-inline-block"><a href="javascript:void(0)" onclick="post_toast('/banaward/comment/{{c.id}}')"><i class="fas fa-user-slash text-danger"></i>Ban user</a></li>
{% endif %}
{% if v and c.id in v.saved_comment_idlist() %}
@ -452,7 +452,7 @@
<li class="list-group-item"><a href="/votes?link=https://rdrama.net{{c.permalink}}"><i class="fas fa-arrows-v"></i>Votes</a></li>
{% if v and v.id!=p.author_id %}
<li class="list-group-item"><a href="javascript:void(0)" onclick="post('/banaward/comment/{{c.id}}', function(){window.location.reload(true);})"><i class="fas fa-user-slash text-danger"></i>Ban user</a></li>
<li class="list-group-item"><a href="javascript:void(0)" onclick="post_toast('/banaward/comment/{{c.id}}')"><i class="fas fa-user-slash text-danger"></i>Ban user</a></li>
{% endif %}
{% if v and c.id in v.saved_comment_idlist() %}

View File

@ -133,7 +133,7 @@
<button class="btn btn-link btn-block btn-lg text-left text-muted"><a href="/votes?link=https://rdrama.net{{p.permalink}}"><i class="fas fa-arrows-v text-center text-muted mr-3"></i>Votes</a></button>
{% if v and v.id!=p.author_id %}
<button class="btn btn-link btn-block btn-lg text-left text-muted"><a href="javascript:void(0)" onclick="post('/banaward/post/{{p.id}}', function(){window.location.reload(true);})"><i class="fas fa-user-slash text-danger mr-3"></i>Ban user</a></button>
<button class="btn btn-link btn-block btn-lg text-left text-muted"><a href="javascript:void(0)" onclick="post_toast('/banaward/post/{{p.id}}')"><i class="fas fa-user-slash text-danger mr-3"></i>Ban user</a></button>
{% endif %}
{% if v and p.id in v.subscribed_idlist() %}
@ -325,7 +325,7 @@
<li class="list-inline-item"><a href="/votes?link=https://rdrama.net{{p.permalink}}"><i class="fas fa-arrows-v"></i>Votes</a></li>
{% if v and v.id!=p.author_id %}
<li class="list-inline-item"><a href="javascript:void(0)" onclick="post('/banaward/post/{{p.id}}', function(){window.location.reload(true);})"><i class="fas fa-user-slash text-danger"></i>Ban user</a></li>
<li class="list-inline-item"><a href="javascript:void(0)" onclick="post_toast('/banaward/post/{{p.id}}')"><i class="fas fa-user-slash text-danger"></i>Ban user</a></li>
{% endif %}
<li class="list-inline-item"><a href="javascript:void(0);" role="button" class="copy-link" data-clipboard-text="{{p.permalink | full_link}}"><i class="fas fa-copy"></i>Copy link</a></li>

View File

@ -193,7 +193,7 @@
<li class="list-inline-item"><a href="/votes?link=https://rdrama.net{{p.permalink}}"><i class="fas fa-arrows-v"></i>Votes</a></li>
{% if v and v.id!=p.author_id %}
<li class="list-inline-item"><a href="javascript:void(0)" onclick="post('/banaward/post/{{p.id}}', function(){window.location.reload(true);})"><i class="fas fa-user-slash text-danger"></i>Ban user</a></li>
<li class="list-inline-item"><a href="javascript:void(0)" onclick="post_toast('/banaward/post/{{p.id}}')"><i class="fas fa-user-slash text-danger"></i>Ban user</a></li>
{% endif %}
<li class="list-inline-item"><a href="javascript:void(0);" role="button" class="copy-link" data-clipboard-text="{{p.permalink | full_link}}"><i class="fas fa-copy"></i>Copy link</a></li>
@ -374,8 +374,10 @@
<ul class="list-group post-actions">
<button class="btn btn-link btn-block btn-lg text-left text-muted"><a href="/votes?link=https://rdrama.net{{p.permalink}}"><i class="fas fa-arrows-v text-center text-muted mr-3"></i>Votes</a></button>
<li id="block-user-{{p.base36id}}" class="list-inline-item {% if p.is_blocking %} d-none{% endif %}"><a href="javascript:void(0)" onclick="post_toast('/settings/block?username={{p.author.username}}', callback=function(){window.location.reload(true);})"><i class="fas fa-user-slash"></i>Block user</a></li>
{% if v and v.id!=p.author_id %}
<button class="btn btn-link btn-block btn-lg text-left text-muted"><a href="javascript:void(0)" onclick="post('/banaward/post/{{p.id}}', function(){window.location.reload(true);})"><i class="fas fa-user-slash text-danger mr-3"></i>Ban user</a></button>
<button class="btn btn-link btn-block btn-lg text-left text-muted"><a href="javascript:void(0)" onclick="post_toast('/banaward/post/{{p.id}}')"><i class="fas fa-user-slash text-danger mr-3"></i>Ban user</a></button>
{% endif %}
{% if v and p.id in v.subscribed_idlist() %}