reporting improvement

remotes/1693045480750635534/spooky-22
Aevann1 2022-09-12 11:48:01 +02:00
parent 2ffe0d527e
commit 7e811b47fb
6 changed files with 24 additions and 31 deletions

View File

@ -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 {

View File

@ -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 {

View File

@ -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()

View File

@ -795,17 +795,15 @@
<span aria-hidden="true"><i class="far fa-times"></i></span>
</button>
</div>
<div class="" id="reportCommentFormBefore">
<div class="modal-body">
<div class="h6">We're sorry something here is wrong.</div>
<small class="form-text text-muted">Please enter a reason for reporting below.</small>
<pre></pre>
<input autocomplete="off" maxlength="100" id="reason_comment" class="form-control">
</div>
<div class="modal-footer">
<button class="btn btn-link text-muted" data-bs-dismiss="modal">Cancel</button>
<button id="reportCommentButton" class="btn btn-danger">Report comment</button>
</div>
<div class="modal-body">
<div class="h6">We're sorry something here is wrong.</div>
<small class="form-text text-muted">Please enter a reason for reporting below.</small>
<pre></pre>
<input autocomplete="off" maxlength="100" id="reason_comment" class="form-control">
</div>
<div class="modal-footer">
<button class="btn btn-link text-muted" data-bs-dismiss="modal">Cancel</button>
<button id="reportCommentButton" class="btn btn-danger" data-bs-dismiss="modal">Report comment</button>
</div>
</div>
</div>

View File

@ -7,20 +7,18 @@
<span aria-hidden="true"><i class="far fa-times"></i></span>
</button>
</div>
<div id="reportPostFormBefore">
<div class="modal-body">
<div class="h6">We're sorry something here is wrong.</div>
<small class="form-text text-muted">Please enter a reason for reporting below.</small>
<pre></pre>
<input autocomplete="off" maxlength="100" id="reason_post" class="form-control b2">
</div>
<div class="modal-footer">
<button class="btn btn-link text-muted" data-bs-dismiss="modal">Cancel</button>
<button id="reportPostButton" class="btn btn-danger">Report post</button>
</div>
<div class="modal-body">
<div class="h6">We're sorry something here is wrong.</div>
<small class="form-text text-muted">Please enter a reason for reporting below.</small>
<pre></pre>
<input autocomplete="off" maxlength="100" id="reason_post" class="form-control b2">
</div>
<div class="modal-footer">
<button class="btn btn-link text-muted" data-bs-dismiss="modal">Cancel</button>
<button id="reportPostButton" class="btn btn-danger" data-bs-dismiss="modal">Report post</button>
</div>
</div>
</div>
</div>
<script defer src="/assets/js/report_post_modal.js?v=4001"></script>
<script defer src="/assets/js/report_post_modal.js?v=4002"></script>

View File

@ -19,7 +19,7 @@ set CACHE_VER = {
'js/bootstrap.js': 4004,
'js/category_modal.js': 4000,
'js/comments_admin.js': 4000,
'js/comments_v.js': 4001,
'js/comments_v.js': 4002,
'js/submission_listing.js': 4000,
'js/emoji_modal.js': 4004,
'js/formatting.js': 4000,