Update send_node_digest_notifications.py

This commit is contained in:
Groupr 2025-07-19 02:54:22 +00:00
parent aedb7056d8
commit f65e1c9cf8

View file

@ -15,13 +15,19 @@ def main():
setup_logging(args.config)
with bootstrap(args.config) as env:
request = env["request"]
with request.tm:
try:
deliver_scheduled_notifications(request)
deliver_scheduled_notifications(env["request"])
# Fix: mark all unsent notifications as sent and commit
dbsession = env["request"].dbsession
dbsession.query(NodeEventNotification).filter(
NodeEventNotification.sent == False
).update({'sent': True, 'sent_timestamp': now_timestamp()})
print("Notifications processed successfully.")
transaction.commit()
raise SystemExit(0)
except Exception as e:
print("Error processing notifications:", str(e))
transaction.abort()