From 58ea9ef3a696787a0d5cae4ca8ddddc52b9bb379 Mon Sep 17 00:00:00 2001 From: Aevann Date: Wed, 6 Mar 2024 00:45:18 +0200 Subject: [PATCH] fix 500 error when something that used to be send_notification or send_repeatable_notification becomes add_notif --- files/helpers/alerts.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/files/helpers/alerts.py b/files/helpers/alerts.py index be1f90ab7..e63273c8d 100644 --- a/files/helpers/alerts.py +++ b/files/helpers/alerts.py @@ -76,17 +76,15 @@ def notif_comment(text): ).order_by(Comment.id).all() if len(existing) > 1: - replace_with = existing[0][0] - replaced = [x[0] for x in existing[1:]] + to_delete = [x[0] for x in existing[1:]] - for n in g.db.query(Notification).filter(Notification.comment_id.in_(replaced)): - n.comment_id = replace_with - g.db.add(n) + for n in g.db.query(Notification).filter(Notification.comment_id.in_(to_delete)): + g.db.delete(n) - for c in g.db.query(Comment).filter(Comment.id.in_(replaced)): + for c in g.db.query(Comment).filter(Comment.id.in_(to_delete)): g.db.delete(c) - return replace_with + return existing[0][0] elif existing: return existing[0][0] else: