diff --git a/files/helpers/alerts.py b/files/helpers/alerts.py index 2cc16b921..59210d7d8 100644 --- a/files/helpers/alerts.py +++ b/files/helpers/alerts.py @@ -19,7 +19,7 @@ def send_notification(uid, text, autojanny=False): new_comment = Comment(author_id=author_id, parent_submission=None, - distinguish_level=6, + distinguish_level=6,body=text, body_html=text_html, notifiedto=uid ) diff --git a/files/routes/users.py b/files/routes/users.py index c6eacf8fe..0142226b1 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -318,16 +318,18 @@ def message2(v, username): message = request.values.get("message", "").strip()[:1000].strip() - existing = g.db.query(Comment.id).filter(Comment.author_id == v.id, - Comment.sentto == user.id, - Comment.body == message, - ).first() - if existing: return redirect('/notifications?messages=true') + message = re.sub('!\[\]\((.*?)\)', r'\1', message) text_html = Renderer().render(mistletoe.Document(message)) text_html = sanitize(text_html, True) + existing = g.db.query(Comment.id).filter(Comment.author_id == v.id, + Comment.sentto == user.id, + Comment.body_html == text_html, + ).first() + if existing: return redirect('/notifications?messages=true') + new_comment = Comment(author_id=v.id, parent_submission=None, level=1, @@ -371,12 +373,16 @@ def message2(v, username): def messagereply(v): message = request.values.get("body", "").strip()[:1000].strip() + + message = re.sub('!\[\]\((.*?)\)', r'\1', message) + id = int(request.values.get("parent_id")) parent = get_comment(id, v=v) user = parent.author text_html = Renderer().render(mistletoe.Document(message)) text_html = sanitize(text_html, True) + new_comment = Comment(author_id=v.id, parent_submission=None, parent_comment_id=id,