diff --git a/app/dao/notifications_dao.py b/app/dao/notifications_dao.py index bbb355bbe..a5a2c5cca 100644 --- a/app/dao/notifications_dao.py +++ b/app/dao/notifications_dao.py @@ -1,7 +1,7 @@ from datetime import timedelta from flask import current_app -from sqlalchemy import asc, delete, desc, func, insert, or_, select, text, union, update +from sqlalchemy import asc, delete, desc, func, or_, select, text, union, update from sqlalchemy.orm import joinedload from sqlalchemy.orm.exc import NoResultFound from sqlalchemy.sql import functions @@ -71,11 +71,11 @@ def dao_create_notification(notification): # notify-api-742 remove phone numbers from db notification.to = "1" notification.normalised_to = "1" - stmt = ( - insert(Notification).values(notification.serialize()).on_conflict_do_nothing() - ) - db.session.execute(stmt) - db.session.commit() + + stmt = select(Notification).where(id=notification.id) + result = db.session.execute(stmt).scalar() + if result is None: + db.session.add(notification) def country_records_delivery(phone_prefix):