From 538497eb5596c9832a78c6cde122ce05647a1db6 Mon Sep 17 00:00:00 2001 From: justcool393 Date: Sat, 12 Nov 2022 20:48:33 -0600 Subject: [PATCH] antispam: hook up duplicate checker --- files/routes/static.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/files/routes/static.py b/files/routes/static.py index 53f40da04..88bb13ec3 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -213,13 +213,17 @@ def submit_contact(v): abort(403) body = f'This message has been sent automatically to all admins via [/contact](/contact)\n\nMessage:\n\n' + body - body += process_files() - body = body.strip() - body_html = sanitize(body) + existing = g.db.query(Comment.id).filter(Comment.author_id == v.id, + Comment.parent_submission == None, + Comment.level == 1, + Comment.sentto == 2, + Comment.body_html == body_html).first() + if existing: abort(409, f"You already sent that message") + new_comment = Comment(author_id=v.id, parent_submission=None, level=1,