Commit b8632d8f authored by Pelayo Torres's avatar Pelayo Torres
Browse files

one_time event logic

parent f6120f0b
Loading
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -150,6 +150,11 @@ class Notifications():
                        notification = {"notification": data.to_dict(), "next_report_time" : next_report_time, "url": url, "subscription_id": sub["subscription_id"]}

                        self.events_ops.add_notification(notification)
                        self.events_ops.update_report_nbr(sub["subscription_id"])

                    if sub["event_req"]["notif_method"] == "ONE_TIME":
                        asyncio.run(self.send(url, serialize_clean_camel_case(data)))
                        self.events_ops.delete_subscription(sub["subscription_id"])
                    
                    if sub["event_req"].get("max_report_nbr", None) and sub["report_nbr"] + 1 == sub["event_req"].get("max_report_nbr", None):
                        current_app.logger.debug(f"Limit reached, deleting subscription {sub['subscription_id']}")
@@ -157,7 +162,6 @@ class Notifications():

                else:
                    asyncio.run(self.send(url, serialize_clean_camel_case(data)))
                
                    self.events_ops.update_report_nbr(sub["subscription_id"])