remotes/1693045480750635534/spooky-22
Aevann1 2021-08-31 19:15:46 +02:00
parent 9b41e55fc1
commit 71b07e0798
2 changed files with 6 additions and 7 deletions

View File

@ -170,12 +170,15 @@ def message2(v, username):
def messagereply(v): def messagereply(v):
message = request.form.get("body", "")[:1000].strip() message = request.form.get("body", "")[:1000].strip()
user = request.form.get("sentto") id = request.form.get("parent_id")
print(id)
parent = get_comment(int(id), v=v)
user = parent.author
message = message.replace("\n", "\n\n").replace("\n\n\n\n\n\n", "\n\n").replace("\n\n\n\n", "\n\n").replace("\n\n\n", "\n\n") message = message.replace("\n", "\n\n").replace("\n\n\n\n\n\n", "\n\n").replace("\n\n\n\n", "\n\n").replace("\n\n\n", "\n\n")
# check existing # check existing
existing = g.db.query(Comment).join(CommentAux).filter(Comment.author_id == v.id, existing = g.db.query(Comment).join(CommentAux).filter(Comment.author_id == v.id,
Comment.sentto == user, Comment.sentto == user.id,
CommentAux.body == message, CommentAux.body == message,
).options(contains_eager(Comment.comment_aux)).first() ).options(contains_eager(Comment.comment_aux)).first()
if existing: if existing:
@ -184,9 +187,6 @@ def messagereply(v):
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) text_html = sanitize(text_html)
id = request.form.get("parent_id")
print(id)
parent = get_comment(int(id), v=v)
new_comment = Comment(author_id=v.id, new_comment = Comment(author_id=v.id,
parent_submission=None, parent_submission=None,
parent_comment_id=id, parent_comment_id=id,
@ -200,7 +200,7 @@ def messagereply(v):
notif = Notification(comment_id=new_comment.id, user_id=user) notif = Notification(comment_id=new_comment.id, user_id=user)
g.db.add(notif) g.db.add(notif)
cache.delete_memoized(User.notification_messages, get_account(user)) cache.delete_memoized(User.notification_messages, user)
return jsonify({"html": render_template("comments.html", return jsonify({"html": render_template("comments.html",
v=v, v=v,

View File

@ -171,7 +171,6 @@
<form class="d-none" id="reply-to-message-{{c.id}}" action="/reply" method="post" class="input-group" enctype="multipart/form-data"> <form class="d-none" id="reply-to-message-{{c.id}}" action="/reply" method="post" class="input-group" enctype="multipart/form-data">
<input type="hidden" name="formkey" value="{{v.formkey}}"> <input type="hidden" name="formkey" value="{{v.formkey}}">
<input type="hidden" name="sentto" value="{{c.author.username}}">
<textarea name="body" form="reply-to-t3_{{c.id}}" class="comment-box form-control rounded" id="reply-form-body-{{c.id}}" aria-label="With textarea" rows="3"></textarea> <textarea name="body" form="reply-to-t3_{{c.id}}" class="comment-box form-control rounded" id="reply-form-body-{{c.id}}" aria-label="With textarea" rows="3"></textarea>
<div class="comment-format" id="comment-format-bar-{{c.id}}"> <div class="comment-format" id="comment-format-bar-{{c.id}}">
<label class="btn btn-secondary format d-inline-block m-0" for="gif-reply-btn-{{c.id}}"> <label class="btn btn-secondary format d-inline-block m-0" for="gif-reply-btn-{{c.id}}">