From 4cc4f8f14fb8c859ae90809aab8eb9dbedd324e0 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sun, 8 May 2022 06:01:42 +0200 Subject: [PATCH] sfd --- files/helpers/alerts.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/files/helpers/alerts.py b/files/helpers/alerts.py index a08655ecad..43bf01f671 100644 --- a/files/helpers/alerts.py +++ b/files/helpers/alerts.py @@ -54,7 +54,19 @@ def notif_comment(text, autojanny=False): text_html = sanitize(text, alert=alert) - existing = g.db.query(Comment.id).filter_by(author_id=author_id, parent_submission=None, body_html=text_html).one_or_none() + try: existing = g.db.query(Comment.id).filter_by(author_id=author_id, parent_submission=None, body_html=text_html).one_or_none() + except: + existing = g.db.query(Comment).filter_by(author_id=author_id, parent_submission=None, body_html=text_html).all() + + + notifs = g.db.query(Notification).filter(Notification.comment_id.in_([x.id for x in existing])).all() + for c in notifs: g.db.delete(c) + g.db.flush() + + + for c in existing: g.db.delete(c) + g.db.flush() + existing = g.db.query(Comment.id).filter_by(author_id=author_id, parent_submission=None, body_html=text_html).one_or_none() if existing: return existing[0] else: return create_comment(text_html, autojanny)