forked from rDrama/rDrama
dont wipe saved shit in /submit unless post is successful
parent
e5fb424bd3
commit
5708d4d64e
|
@ -180,17 +180,20 @@ function submit(form) {
|
||||||
upload_prog.classList.add("d-none")
|
upload_prog.classList.add("d-none")
|
||||||
|
|
||||||
if (xhr.status >= 200 && xhr.status < 300) {
|
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", "")
|
if (res['success']) {
|
||||||
localStorage.setItem("post-text", "")
|
localStorage.setItem("post-title", "")
|
||||||
localStorage.setItem("post-url", "")
|
localStorage.setItem("post-text", "")
|
||||||
localStorage.setItem("sub", "")
|
localStorage.setItem("post-url", "")
|
||||||
localStorage.setItem("post-notify", true)
|
localStorage.setItem("sub", "")
|
||||||
localStorage.setItem("post-new", false)
|
localStorage.setItem("post-notify", true)
|
||||||
localStorage.setItem("post-nsfw", false)
|
localStorage.setItem("post-new", false)
|
||||||
localStorage.setItem("post-private", false)
|
localStorage.setItem("post-nsfw", false)
|
||||||
localStorage.setItem("post-ghost", false)
|
localStorage.setItem("post-private", false)
|
||||||
|
localStorage.setItem("post-ghost", false)
|
||||||
|
}
|
||||||
|
|
||||||
location.href = "/post/" + post_id
|
location.href = "/post/" + post_id
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -513,7 +513,7 @@ def submit_post(v:User, sub=None):
|
||||||
Submission.is_banned == False
|
Submission.is_banned == False
|
||||||
).first()
|
).first()
|
||||||
if repost and FEATURES['REPOST_DETECTION'] and not v.admin_level >= PERMS['POST_BYPASS_REPOST_CHECKING']:
|
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 = tldextract.extract(url).registered_domain + parsed_url.path
|
||||||
y = y.lower()
|
y = y.lower()
|
||||||
|
@ -547,7 +547,7 @@ def submit_post(v:User, sub=None):
|
||||||
Submission.body == body
|
Submission.body == body
|
||||||
).one_or_none()
|
).one_or_none()
|
||||||
if dup:
|
if dup:
|
||||||
return {"post_id": dup.id}
|
return {"post_id": dup.id, "success": False}
|
||||||
|
|
||||||
if not execute_antispam_submission_check(title, v, url):
|
if not execute_antispam_submission_check(title, v, url):
|
||||||
return redirect("/notifications")
|
return redirect("/notifications")
|
||||||
|
@ -704,7 +704,7 @@ def submit_post(v:User, sub=None):
|
||||||
if v.client: return p.json(g.db)
|
if v.client: return p.json(g.db)
|
||||||
else:
|
else:
|
||||||
p.voted = 1
|
p.voted = 1
|
||||||
return {"post_id": p.id}
|
return {"post_id": p.id, "success": True}
|
||||||
|
|
||||||
@app.post("/delete_post/<int:pid>")
|
@app.post("/delete_post/<int:pid>")
|
||||||
@limiter.limit('1/second', scope=rpath)
|
@limiter.limit('1/second', scope=rpath)
|
||||||
|
|
Loading…
Reference in New Issue