From d616086dbd82209cba199e1aa82ae6e1b31499a4 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Mon, 7 Nov 2022 01:48:37 +0200 Subject: [PATCH] fix logic for duplicate posts in localhost --- files/routes/posts.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/files/routes/posts.py b/files/routes/posts.py index ab09f7dd8..567f874c8 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -724,15 +724,15 @@ def submit_post(v, sub=None): if not url and not body and not request.files.get("file") and not request.files.get("file-url"): return error("Please enter a url or some text.") - dup = g.db.query(Submission).filter( - Submission.author_id == v.id, - Submission.deleted_utc == 0, - Submission.title == title, - Submission.url == url, - Submission.body == body - ).one_or_none() - - if dup and SITE != 'localhost': return redirect(dup.permalink) + if SITE != 'localhost': + dup = g.db.query(Submission).filter( + Submission.author_id == v.id, + Submission.deleted_utc == 0, + Submission.title == title, + Submission.url == url, + Submission.body == body + ).one_or_none() + if dup: return redirect(dup.permalink) if not execute_antispam_submission_check(title, v, url): return redirect("/notifications")