From 30e5a93f2eeebfb35af484642b5837c0733ac483 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 24 Jul 2021 20:15:26 +0200 Subject: [PATCH] fd --- drama/classes/flags.py | 2 ++ drama/routes/flagging.py | 5 ++++- drama/routes/users.py | 4 ++-- drama/templates/default.html | 12 ++++++------ 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/drama/classes/flags.py b/drama/classes/flags.py index 6110459c6..631b7dd76 100644 --- a/drama/classes/flags.py +++ b/drama/classes/flags.py @@ -10,6 +10,7 @@ class Flag(Base, Stndrd): id = Column(Integer, primary_key=True) post_id = Column(Integer, ForeignKey("submissions.id")) user_id = Column(Integer, ForeignKey("users.id")) + reason = Column(String(100), default=None) created_utc = Column(Integer) user = relationship("User", lazy = "joined", primaryjoin = "Flag.user_id == User.id", uselist = False) @@ -26,6 +27,7 @@ class CommentFlag(Base, Stndrd): id = Column(Integer, primary_key=True) user_id = Column(Integer, ForeignKey("users.id")) comment_id = Column(Integer, ForeignKey("comments.id")) + reason = Column(String(100), default=None) created_utc = Column(Integer) user = relationship("User", lazy = "joined", primaryjoin = "CommentFlag.user_id == User.id", uselist = False) diff --git a/drama/routes/flagging.py b/drama/routes/flagging.py index b7fc52813..47c723456 100644 --- a/drama/routes/flagging.py +++ b/drama/routes/flagging.py @@ -17,9 +17,10 @@ def api_flag_post(pid, v): if existing: return "", 409 - + reason = request.form.get("reason", "")[:100].strip() flag = Flag(post_id=post.id, user_id=v.id, + reason=reason, created_utc=int(time.time()) ) @@ -43,8 +44,10 @@ def api_flag_comment(cid, v): if existing: return "", 409 + reason = request.form.get("reason", "")[:100].strip() flag = CommentFlag(comment_id=comment.id, user_id=v.id, + reason=reason, created_utc=int(time.time()) ) diff --git a/drama/routes/users.py b/drama/routes/users.py index 04217b36f..22e044051 100644 --- a/drama/routes/users.py +++ b/drama/routes/users.py @@ -64,7 +64,7 @@ def get_profilecss(username): @app.route("/@/reply/", methods=["POST"]) @auth_required def messagereply(v, username, id): - message = request.form.get("message", "") + message = request.form.get("message", "")[:1000].strip() user = get_user(username) with CustomRenderer() as renderer: text_html = renderer.render(mistletoe.Document(message)) text_html = sanitize(text_html, linkgen=True) @@ -113,7 +113,7 @@ def message2(v, username): user = get_user(username, v=v) if user.is_blocking: return jsonify({"error": "You're blocking this user."}), 403 if user.is_blocked: return jsonify({"error": "This user is blocking you."}), 403 - message = request.form.get("message", "") + message = request.form.get("message", "")[:1000].strip() send_pm(v.id, user, message) beams_client.publish_to_interests( interests=[str(user.id)], diff --git a/drama/templates/default.html b/drama/templates/default.html index 597f3ba0d..a6289e848 100644 --- a/drama/templates/default.html +++ b/drama/templates/default.html @@ -260,12 +260,11 @@ document.getElementById("post-author").textContent = author; - selectbox=document.getElementById('report-type-dropdown'); - selectbox.value='reason_not_selected'; - submitbutton=document.getElementById("reportPostButton"); submitbutton.disabled=true; + reason=document.getElementById("reason").value; + submitbutton.onclick = function() { this.innerHTML='Reporting post'; @@ -275,9 +274,7 @@ xhr.open("POST", '/api/flag/post/'+id, true); var form = new FormData() form.append("formkey", formkey()); - - dropdown=document.getElementById("report-type-dropdown"); - form.append("report_type", dropdown.options[dropdown.selectedIndex].value); + form.append("reason", reason); xhr.withCredentials=true; @@ -310,6 +307,9 @@ }); + + + $('.expandable-image').click( function(event) { if (event.which != 1) {