diff --git a/files/assets/js/comments_v.js b/files/assets/js/comments_v.js index b75f0dda1..fbf1152cb 100644 --- a/files/assets/js/comments_v.js +++ b/files/assets/js/comments_v.js @@ -122,6 +122,8 @@ function post_reply(id){ commentForm.innerHTML = xhr.response.replace(/data-src/g, 'src').replace(/data-cfsrc/g, 'src').replace(/style="display:none;visibility:hidden;"/g, '').replace('comment-collapse-desktop d-none d-md-block','d-none').replace('border-left: 2px solid','padding-left:0;border-left: 0px solid'); } else { + let data = JSON.parse(xhr.response) + if (data && data["error"]) document.getElementById('toast-post-error-text').innerText = data["error"]; new bootstrap.Toast(document.getElementById('toast-post-error')).show(); } } @@ -146,6 +148,8 @@ function comment_edit(id){ document.getElementById('cancel-edit-'+id).click() } else { + let data = JSON.parse(xhr.response) + if (data && data["error"]) document.getElementById('toast-post-error-text').innerText = data["error"]; new bootstrap.Toast(document.getElementById('toast-post-error')).show(); } } @@ -173,6 +177,8 @@ function post_comment(fullname){ commentForm.innerHTML = xhr.response.replace(/data-src/g, 'src').replace(/data-cfsrc/g, 'src').replace(/style="display:none;visibility:hidden;"/g, ''); } else { + let data = JSON.parse(xhr.response) + if (data && data["error"]) document.getElementById('toast-post-error-text').innerText = data["error"]; new bootstrap.Toast(document.getElementById('toast-post-error')).show(); btn.classList.remove('disabled'); } diff --git a/files/helpers/alerts.py b/files/helpers/alerts.py index 6f3e78de0..7c743d4e4 100644 --- a/files/helpers/alerts.py +++ b/files/helpers/alerts.py @@ -102,9 +102,10 @@ def NOTIFY_USERS(text, v): if word in text.lower() and id not in notify_users and v.id != id: notify_users.add(id) soup = BeautifulSoup(text, features="html.parser") - for mention in soup.find_all("a", href=re.compile("^/@(\w+)")): - username = mention["href"].split("@")[1] - user = g.db.query(User).filter_by(username=username).one_or_none() - if user and not v.any_block_exists(user) and user.id != v.id: notify_users.add(user.id) + for mention in soup.find_all("a", href=re.compile("^\/id\/([0-9]+)")): + id = mention["href"].split("/id/")[1] + if id != v.id: + user = g.db.query(User).filter_by(id=id).one_or_none() + if user and not v.any_block_exists(user): notify_users.add(user.id) return notify_users \ No newline at end of file diff --git a/files/templates/comments.html b/files/templates/comments.html index f817cc1e6..efa09c8d5 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -518,31 +518,7 @@ {% if render_replies %} - {% if level<10 %} -