diff --git a/frappe/email/doctype/unhandled_email/unhandled_email.py b/frappe/email/doctype/unhandled_email/unhandled_email.py index 77ba8aea13..1276da71a1 100644 --- a/frappe/email/doctype/unhandled_email/unhandled_email.py +++ b/frappe/email/doctype/unhandled_email/unhandled_email.py @@ -8,3 +8,8 @@ from frappe.model.document import Document class UnhandledEmail(Document): pass + + +def remove_old_unhandled_emails(): + frappe.db.sql("""DELETE FROM `tabUnhandled Email` + WHERE creation < %s""", frappe.utils.add_days(frappe.utils.nowdate(), -30)) diff --git a/frappe/hooks.py b/frappe/hooks.py index a35fd78ebb..b35387efe9 100644 --- a/frappe/hooks.py +++ b/frappe/hooks.py @@ -188,7 +188,8 @@ scheduler_events = { "frappe.social.doctype.energy_point_settings.energy_point_settings.allocate_review_points", "frappe.integrations.doctype.google_contacts.google_contacts.sync", "frappe.automation.doctype.auto_repeat.auto_repeat.make_auto_repeat_entry", - "frappe.automation.doctype.auto_repeat.auto_repeat.set_auto_repeat_as_completed" + "frappe.automation.doctype.auto_repeat.auto_repeat.set_auto_repeat_as_completed", + "frappe.email.doctype.unhandled_email.unhandled_email.remove_old_unhandled_emails" ], "daily_long": [ "frappe.integrations.doctype.dropbox_settings.dropbox_settings.take_backups_daily", diff --git a/frappe/patches.txt b/frappe/patches.txt index 8321debf3a..efb9dd5bbb 100644 --- a/frappe/patches.txt +++ b/frappe/patches.txt @@ -254,3 +254,4 @@ frappe.patches.v12_0.delete_duplicate_indexes frappe.patches.v12_0.set_default_incoming_email_port frappe.patches.v12_0.update_global_search execute:frappe.reload_doc('desk', 'doctype', 'notification_settings') +execute:frappe.email.doctype.unhandled_email.unhandled_email.remove_old_unhandled_emails