forked from rDrama/rDrama
fix 500 error when something that used to be send_notification or send_repeatable_notification becomes add_notif
parent
9bebdde4d3
commit
58ea9ef3a6
|
@ -76,17 +76,15 @@ def notif_comment(text):
|
||||||
).order_by(Comment.id).all()
|
).order_by(Comment.id).all()
|
||||||
|
|
||||||
if len(existing) > 1:
|
if len(existing) > 1:
|
||||||
replace_with = existing[0][0]
|
to_delete = [x[0] for x in existing[1:]]
|
||||||
replaced = [x[0] for x in existing[1:]]
|
|
||||||
|
|
||||||
for n in g.db.query(Notification).filter(Notification.comment_id.in_(replaced)):
|
for n in g.db.query(Notification).filter(Notification.comment_id.in_(to_delete)):
|
||||||
n.comment_id = replace_with
|
g.db.delete(n)
|
||||||
g.db.add(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)
|
g.db.delete(c)
|
||||||
|
|
||||||
return replace_with
|
return existing[0][0]
|
||||||
elif existing:
|
elif existing:
|
||||||
return existing[0][0]
|
return existing[0][0]
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue