dont wipe saved shit in /submit unless post is successful

pull/137/head
Aevann 2023-03-09 07:52:20 +02:00
parent e5fb424bd3
commit 5708d4d64e
2 changed files with 16 additions and 13 deletions

View File

@ -180,17 +180,20 @@ function submit(form) {
upload_prog.classList.add("d-none")
if (xhr.status >= 200 && xhr.status < 300) {
const post_id = JSON.parse(xhr.response)['post_id'];
const res = JSON.parse(xhr.response)
const post_id = res['post_id'];
localStorage.setItem("post-title", "")
localStorage.setItem("post-text", "")
localStorage.setItem("post-url", "")
localStorage.setItem("sub", "")
localStorage.setItem("post-notify", true)
localStorage.setItem("post-new", false)
localStorage.setItem("post-nsfw", false)
localStorage.setItem("post-private", false)
localStorage.setItem("post-ghost", false)
if (res['success']) {
localStorage.setItem("post-title", "")
localStorage.setItem("post-text", "")
localStorage.setItem("post-url", "")
localStorage.setItem("sub", "")
localStorage.setItem("post-notify", true)
localStorage.setItem("post-new", false)
localStorage.setItem("post-nsfw", false)
localStorage.setItem("post-private", false)
localStorage.setItem("post-ghost", false)
}
location.href = "/post/" + post_id
} else {

View File

@ -513,7 +513,7 @@ def submit_post(v:User, sub=None):
Submission.is_banned == False
).first()
if repost and FEATURES['REPOST_DETECTION'] and not v.admin_level >= PERMS['POST_BYPASS_REPOST_CHECKING']:
return {"post_id": repost.id}
return {"post_id": repost.id, "success": False}
y = tldextract.extract(url).registered_domain + parsed_url.path
y = y.lower()
@ -547,7 +547,7 @@ def submit_post(v:User, sub=None):
Submission.body == body
).one_or_none()
if dup:
return {"post_id": dup.id}
return {"post_id": dup.id, "success": False}
if not execute_antispam_submission_check(title, v, url):
return redirect("/notifications")
@ -704,7 +704,7 @@ def submit_post(v:User, sub=None):
if v.client: return p.json(g.db)
else:
p.voted = 1
return {"post_id": p.id}
return {"post_id": p.id, "success": True}
@app.post("/delete_post/<int:pid>")
@limiter.limit('1/second', scope=rpath)