diff --git a/remarkbox/lib/notify.py b/remarkbox/lib/notify.py index 04f14ab..0685be6 100644 --- a/remarkbox/lib/notify.py +++ b/remarkbox/lib/notify.py @@ -166,7 +166,7 @@ def deliver_scheduled_notifications(request=None): if datetime.today().weekday() == 0: notification_dict = get_email_notifications(request.dbsession, "weekly") send_digest_notifications(request, notification_dict, "weekly") - + def send_immediate_notifications(request, notifications): deliver_email_notifications = request.app.get("deliver_email_notifications", True) diff --git a/remarkbox/scripts/send_node_digest_notifications.py b/remarkbox/scripts/send_node_digest_notifications.py index cd684c0..6de10f2 100644 --- a/remarkbox/scripts/send_node_digest_notifications.py +++ b/remarkbox/scripts/send_node_digest_notifications.py @@ -15,13 +15,17 @@ def main(): setup_logging(args.config) with bootstrap(args.config) as env: - try: - deliver_scheduled_notifications() - print("Notifications processed successfully.") - raise SystemExit(0) - except Exception as e: - print("Error processing notifications:", str(e)) - raise SystemExit(1) + request = env["request"] + with request.tm: + try: + deliver_scheduled_notifications() + print("Notifications processed successfully.") + transaction.commit() + raise SystemExit(0) + except Exception as e: + print("Error processing notifications:", str(e)) + transaction.abort() + raise SystemExit(1) if __name__ == "__main__": main()