diff --git a/ruqqus/routes/comments.py b/ruqqus/routes/comments.py index ea3f61aa4..3bd26c9ce 100644 --- a/ruqqus/routes/comments.py +++ b/ruqqus/routes/comments.py @@ -24,14 +24,13 @@ beams_client = PushNotifications( @app.route("/banaward/comment/", 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//comment/", methods=["GET"]) def comment_cid_api_redirect(cid=None, pid=None): diff --git a/ruqqus/routes/posts.py b/ruqqus/routes/posts.py index 11b532275..dd5073d98 100644 --- a/ruqqus/routes/posts.py +++ b/ruqqus/routes/posts.py @@ -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/", methods=["POST"]) @is_not_banned diff --git a/ruqqus/templates/comments.html b/ruqqus/templates/comments.html index b06f60afb..66f0e7da5 100644 --- a/ruqqus/templates/comments.html +++ b/ruqqus/templates/comments.html @@ -243,7 +243,7 @@
  • Votes
  • {% if v and v.id!=p.author_id %} -
  • Ban user
  • +
  • Ban user
  • {% endif %} {% if v and c.id in v.saved_comment_idlist() %} @@ -452,7 +452,7 @@
  • Votes
  • {% if v and v.id!=p.author_id %} -
  • Ban user
  • +
  • Ban user
  • {% endif %} {% if v and c.id in v.saved_comment_idlist() %} diff --git a/ruqqus/templates/submission.html b/ruqqus/templates/submission.html index bad578870..617fab175 100644 --- a/ruqqus/templates/submission.html +++ b/ruqqus/templates/submission.html @@ -133,7 +133,7 @@ {% if v and v.id!=p.author_id %} - + {% endif %} {% if v and p.id in v.subscribed_idlist() %} @@ -325,7 +325,7 @@
  • Votes
  • {% if v and v.id!=p.author_id %} -
  • Ban user
  • +
  • Ban user
  • {% endif %}
  • Copy link
  • diff --git a/ruqqus/templates/submission_listing.html b/ruqqus/templates/submission_listing.html index 1cf417a47..a4ddf0636 100644 --- a/ruqqus/templates/submission_listing.html +++ b/ruqqus/templates/submission_listing.html @@ -193,7 +193,7 @@
  • Votes
  • {% if v and v.id!=p.author_id %} -
  • Ban user
  • +
  • Ban user
  • {% endif %}
  • Copy link
  • @@ -374,8 +374,10 @@