remotes/1693045480750635534/spooky-22
Aevann1 2021-07-29 07:50:04 +02:00
parent 7ada3c794c
commit eaa927545e
2 changed files with 13 additions and 6 deletions

View File

@ -37,8 +37,6 @@ def send_notification(vid, user, text):
def send_pm(vid, user, text):
text = text.replace("\n", "\n\n").replace("\n\n\n\n\n\n", "\n\n").replace("\n\n\n\n", "\n\n")
with CustomRenderer() as renderer: text_html = renderer.render(mistletoe.Document(text))
text_html = sanitize(text_html, linkgen=True)

View File

@ -73,6 +73,14 @@ def messagereply(v, username, id):
message = request.form.get("message", "")[:1000].strip()
user = get_user(username)
message = message.replace("\n", "\n\n").replace("\n\n\n\n\n\n", "\n\n").replace("\n\n\n\n", "\n\n")
# check existing
existing = g.db.query(Comment).join(CommentAux).filter(Comment.author_id == v.id,
Comment.sentto == user.id,
CommentAux.body == message,
).options(contains_eager(Comment.comment_aux)).first()
if existing: return redirect('/notifications?all=true')
with CustomRenderer() as renderer: text_html = renderer.render(mistletoe.Document(message))
text_html = sanitize(text_html, linkgen=True)
parent = get_comment(int(id), v=v)
@ -122,12 +130,13 @@ def message2(v, username):
if user.is_blocked: return jsonify({"error": "This user is blocking you."}), 403
message = request.form.get("message", "")[:1000].strip()
message = message.replace("\n", "\n\n").replace("\n\n\n\n\n\n", "\n\n").replace("\n\n\n\n", "\n\n")
# check existing
existing = g.db.query(Comment).join(CommentAux).filter(Comment.author_id == v.id,
Comment.deleted_utc == 0,
Comment.parent_submission == None,
CommentAux.body == message,
).options(contains_eager(Comment.comment_aux)).first()
Comment.sentto == user.id,
CommentAux.body == message,
).options(contains_eager(Comment.comment_aux)).first()
if existing: return redirect('/notifications?all=true')
send_pm(v.id, user, message)