Skip to content

Commit

Permalink
check if notification already exists to prevent duplicate insert atte…
Browse files Browse the repository at this point in the history
…mpts
  • Loading branch information
Kenneth Kehl committed Dec 2, 2024
1 parent 661ef10 commit 56a1b50
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/dao/notifications_dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ def dao_create_notification(notification):
notification.to = "1"
notification.normalised_to = "1"

stmt = select(Notification).where(Notification.id == notification.id)
result = db.session.execute(stmt).scalar()
result = None
if notification.notification_type == NotificationType.SMS:
stmt = select(Notification).where(Notification.id == notification.id)
result = db.session.execute(stmt).scalar()
if result is None:
db.session.add(notification)

Expand Down

0 comments on commit 56a1b50

Please sign in to comment.