remotes/1693045480750635534/spooky-22
Aevann1 2021-07-24 20:15:26 +02:00
parent 71f86e69c7
commit 30e5a93f2e
4 changed files with 14 additions and 9 deletions

View File

@ -10,6 +10,7 @@ class Flag(Base, Stndrd):
id = Column(Integer, primary_key=True) id = Column(Integer, primary_key=True)
post_id = Column(Integer, ForeignKey("submissions.id")) post_id = Column(Integer, ForeignKey("submissions.id"))
user_id = Column(Integer, ForeignKey("users.id")) user_id = Column(Integer, ForeignKey("users.id"))
reason = Column(String(100), default=None)
created_utc = Column(Integer) created_utc = Column(Integer)
user = relationship("User", lazy = "joined", primaryjoin = "Flag.user_id == User.id", uselist = False) 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) id = Column(Integer, primary_key=True)
user_id = Column(Integer, ForeignKey("users.id")) user_id = Column(Integer, ForeignKey("users.id"))
comment_id = Column(Integer, ForeignKey("comments.id")) comment_id = Column(Integer, ForeignKey("comments.id"))
reason = Column(String(100), default=None)
created_utc = Column(Integer) created_utc = Column(Integer)
user = relationship("User", lazy = "joined", primaryjoin = "CommentFlag.user_id == User.id", uselist = False) user = relationship("User", lazy = "joined", primaryjoin = "CommentFlag.user_id == User.id", uselist = False)

View File

@ -17,9 +17,10 @@ def api_flag_post(pid, v):
if existing: if existing:
return "", 409 return "", 409
reason = request.form.get("reason", "")[:100].strip()
flag = Flag(post_id=post.id, flag = Flag(post_id=post.id,
user_id=v.id, user_id=v.id,
reason=reason,
created_utc=int(time.time()) created_utc=int(time.time())
) )
@ -43,8 +44,10 @@ def api_flag_comment(cid, v):
if existing: if existing:
return "", 409 return "", 409
reason = request.form.get("reason", "")[:100].strip()
flag = CommentFlag(comment_id=comment.id, flag = CommentFlag(comment_id=comment.id,
user_id=v.id, user_id=v.id,
reason=reason,
created_utc=int(time.time()) created_utc=int(time.time())
) )

View File

@ -64,7 +64,7 @@ def get_profilecss(username):
@app.route("/@<username>/reply/<id>", methods=["POST"]) @app.route("/@<username>/reply/<id>", methods=["POST"])
@auth_required @auth_required
def messagereply(v, username, id): def messagereply(v, username, id):
message = request.form.get("message", "") message = request.form.get("message", "")[:1000].strip()
user = get_user(username) user = get_user(username)
with CustomRenderer() as renderer: text_html = renderer.render(mistletoe.Document(message)) with CustomRenderer() as renderer: text_html = renderer.render(mistletoe.Document(message))
text_html = sanitize(text_html, linkgen=True) text_html = sanitize(text_html, linkgen=True)
@ -113,7 +113,7 @@ def message2(v, username):
user = get_user(username, v=v) user = get_user(username, v=v)
if user.is_blocking: return jsonify({"error": "You're blocking this user."}), 403 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 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) send_pm(v.id, user, message)
beams_client.publish_to_interests( beams_client.publish_to_interests(
interests=[str(user.id)], interests=[str(user.id)],

View File

@ -260,12 +260,11 @@
document.getElementById("post-author").textContent = author; document.getElementById("post-author").textContent = author;
selectbox=document.getElementById('report-type-dropdown');
selectbox.value='reason_not_selected';
submitbutton=document.getElementById("reportPostButton"); submitbutton=document.getElementById("reportPostButton");
submitbutton.disabled=true; submitbutton.disabled=true;
reason=document.getElementById("reason").value;
submitbutton.onclick = function() { submitbutton.onclick = function() {
this.innerHTML='<span class="spinner-border spinner-border-sm mr-2" role="status" aria-hidden="true"></span>Reporting post'; this.innerHTML='<span class="spinner-border spinner-border-sm mr-2" role="status" aria-hidden="true"></span>Reporting post';
@ -275,9 +274,7 @@
xhr.open("POST", '/api/flag/post/'+id, true); xhr.open("POST", '/api/flag/post/'+id, true);
var form = new FormData() var form = new FormData()
form.append("formkey", formkey()); form.append("formkey", formkey());
form.append("reason", reason);
dropdown=document.getElementById("report-type-dropdown");
form.append("report_type", dropdown.options[dropdown.selectedIndex].value);
xhr.withCredentials=true; xhr.withCredentials=true;
@ -310,6 +307,9 @@
}); });
$('.expandable-image').click( function(event) { $('.expandable-image').click( function(event) {
if (event.which != 1) { if (event.which != 1) {