diff --git a/files/assets/js/comments_v.js b/files/assets/js/comments_v.js index 2c4872414..aa7538312 100644 --- a/files/assets/js/comments_v.js +++ b/files/assets/js/comments_v.js @@ -16,8 +16,6 @@ function report_commentModal(id, author) { document.getElementById("comment-author").textContent = author; - document.getElementById("reportCommentFormBefore").classList.remove('d-none'); - reportCommentButton.innerHTML='Report comment'; reportCommentButton.disabled = false; reportCommentButton.classList.remove('disabled'); @@ -43,7 +41,6 @@ function report_commentModal(id, author) { try {data = JSON.parse(xhr.response)} catch(e) {console.log(e)} if (xhr.status >= 200 && xhr.status < 300 && data && data['message']) { - document.getElementById("reportCommentFormBefore").classList.add('d-none'); document.getElementById('toast-post-success-text').innerText = data["message"]; bootstrap.Toast.getOrCreateInstance(document.getElementById('toast-post-success')).show(); } else { diff --git a/files/assets/js/report_post_modal.js b/files/assets/js/report_post_modal.js index 421438d80..555599e74 100644 --- a/files/assets/js/report_post_modal.js +++ b/files/assets/js/report_post_modal.js @@ -13,7 +13,6 @@ reason_post.addEventListener('keydown', (e) => { function report_postModal(id) { - document.getElementById("reportPostFormBefore").classList.remove('d-none'); reportPostButton.disabled = false; reportPostButton.classList.remove('disabled'); reportPostButton.innerHTML='Report post'; @@ -41,7 +40,6 @@ function report_postModal(id) { try {data = JSON.parse(xhr.response)} catch(e) {console.log(e)} if (xhr.status >= 200 && xhr.status < 300 && data && data['message']) { - document.getElementById("reportPostFormBefore").classList.add('d-none'); document.getElementById('toast-post-success-text').innerText = data["message"]; bootstrap.Toast.getOrCreateInstance(document.getElementById('toast-post-success')).show(); } else { diff --git a/files/routes/reporting.py b/files/routes/reporting.py index 84636c175..588a49873 100644 --- a/files/routes/reporting.py +++ b/files/routes/reporting.py @@ -77,7 +77,8 @@ def flag_post(pid, v): return {"message": f"Post moved to /h/{post.sub}"} else: existing = g.db.query(Flag.post_id).filter_by(user_id=v.id, post_id=post.id).one_or_none() - if existing: return "", 409 + if existing: + return {"error": "You already reported this post!"}, 409 flag = Flag(post_id=post.id, user_id=v.id, reason=reason) g.db.add(flag) @@ -94,7 +95,8 @@ def flag_comment(cid, v): comment = get_comment(cid) existing = g.db.query(CommentFlag.comment_id).filter_by(user_id=v.id, comment_id=comment.id).one_or_none() - if existing: return "", 409 + if existing: + return {"error": "You already reported this comment!"}, 409 reason = request.values.get("reason", "").strip() diff --git a/files/templates/comments.html b/files/templates/comments.html index c67b0a5ad..0c05ca5d9 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -795,17 +795,15 @@
-