diff --git a/frappe_whatsapp/frappe_whatsapp/doctype/whatsapp_notification/whatsapp_notification.py b/frappe_whatsapp/frappe_whatsapp/doctype/whatsapp_notification/whatsapp_notification.py index 5caa3a7..1642ca2 100644 --- a/frappe_whatsapp/frappe_whatsapp/doctype/whatsapp_notification/whatsapp_notification.py +++ b/frappe_whatsapp/frappe_whatsapp/doctype/whatsapp_notification/whatsapp_notification.py @@ -235,24 +235,8 @@ def notify(self, data): def on_trash(self): """On delete remove from schedule.""" - if self.notification_type == "Scheduler Event": - frappe.delete_doc("Scheduled Job Type", self.name) - frappe.cache().delete_value("whatsapp_notification_map") - def after_insert(self): - """After insert hook.""" - if self.notification_type == "Scheduler Event": - method = f"frappe_whatsapp.utils.trigger_whatsapp_notifications_{self.event_frequency.lower().replace(' ', '_')}" # noqa - job = frappe.get_doc( - { - "doctype": "Scheduled Job Type", - "method": method, - "frequency": self.event_frequency - } - ) - - job.insert() def format_number(self, number): """Format number.""" diff --git a/frappe_whatsapp/hooks.py b/frappe_whatsapp/hooks.py index 608e672..0d3969c 100644 --- a/frappe_whatsapp/hooks.py +++ b/frappe_whatsapp/hooks.py @@ -115,18 +115,34 @@ # --------------- scheduler_events = { -# "all": [ -# "frappe_whatsapp.tasks.all" -# ], - "daily": [ - "frappe_whatsapp.frappe_whatsapp.doctype.whatsapp_notification.whatsapp_notification.trigger_notifications" - ], -# "weekly": [ -# "frappe_whatsapp.tasks.weekly" -# ], -# "monthly": [ -# "frappe_whatsapp.tasks.monthly" -# ], + "all": [ + "frappe_whatsapp.utils.trigger_whatsapp_notifications_all" + ], + "hourly": [ + "frappe_whatsapp.utils.trigger_whatsapp_notifications_hourly" + ], + "hourly_long": [ + "frappe_whatsapp.utils.trigger_whatsapp_notifications_hourly_long" + ], + "daily": [ + "frappe_whatsapp.utils.trigger_whatsapp_notifications_daily", + "frappe_whatsapp.frappe_whatsapp.doctype.whatsapp_notification.whatsapp_notification.trigger_notifications", + ], + "daily_long": [ + "frappe_whatsapp.utils.trigger_whatsapp_notifications_daily_long", + ], + "weekly": [ + "frappe_whatsapp.utils.trigger_whatsapp_notifications_weekly", + ], + "weekly_long": [ + "frappe_whatsapp.utils.trigger_whatsapp_notifications_weekly_long", + ], + "monthly": [ + "frappe_whatsapp.utils.trigger_whatsapp_notifications_monthly", + ], + "monthly_long": [ + "frappe_whatsapp.utils.trigger_whatsapp_notifications_monthly_long", + ], } # Testing