From aa9bbe06cdff5bbaf3d47b67089ca1959cb670b3 Mon Sep 17 00:00:00 2001 From: top Date: Thu, 21 Sep 2023 18:09:39 +0000 Subject: [PATCH] Skip multiple autojanny comment error (#204) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Error happens here where multiple autojanny comments are found on a new install, should probably be handled by deleting one of them 🤷. This at least allows new installs to work without some database tinkering Co-authored-by: Chuck Reviewed-on: https://fsdfsd.net/rDrama/rDrama/pulls/204 Co-authored-by: top Co-committed-by: top --- files/helpers/offsitementions.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/files/helpers/offsitementions.py b/files/helpers/offsitementions.py index 114322dd8..42f477a05 100644 --- a/files/helpers/offsitementions.py +++ b/files/helpers/offsitementions.py @@ -84,11 +84,16 @@ def notify_mentions(mentions, send_to=None, mention_str='site mention'): ) g.db.flush() - existing_comment = g.db.query(Comment.id).filter_by( - author_id=const.AUTOJANNY_ID, - parent_post=None, - body_html=notif_text).one_or_none() - if existing_comment: break + try: + existing_comment = g.db.query(Comment.id).filter_by( + author_id=const.AUTOJANNY_ID, + parent_post=None, + body_html=notif_text).one_or_none() + if existing_comment: break + # todo: handle this exception by removing one of the existing + # means that multiple rows were found, happens on new install for some reason + except: + pass new_comment = Comment( author_id=const.AUTOJANNY_ID,