From f12ed9791a2da4a9619c7564ba2bb6dcc64cda80 Mon Sep 17 00:00:00 2001 From: "Chinmay D. Pai" Date: Fri, 17 Jul 2020 11:32:02 +0530 Subject: [PATCH] fix: remove example users email ids from notifications currently the system tries sending emails to all users that have 'thread_notify' enabled, including the default example emails that the Administrator and Guest accounts have. this patch disables email notifications for these accounts, and additionally tries to disable it for any other user accounts with example emails Signed-off-by: Chinmay D. Pai --- frappe/patches.txt | 3 ++- .../patches/v12_0/remove_example_email_thread_notify.py | 8 ++++++++ frappe/utils/install.py | 6 ++++-- 3 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 frappe/patches/v12_0/remove_example_email_thread_notify.py diff --git a/frappe/patches.txt b/frappe/patches.txt index 1108f1fb1b..f8c767f5a3 100644 --- a/frappe/patches.txt +++ b/frappe/patches.txt @@ -273,6 +273,7 @@ execute:frappe.delete_doc_if_exists('DocType', 'GSuite Templates') execute:frappe.delete_doc_if_exists('DocType', 'GCalendar Account') execute:frappe.delete_doc_if_exists('DocType', 'GCalendar Settings') frappe.patches.v12_0.remove_parent_and_parenttype_from_print_formats +frappe.patches.v12_0.remove_example_email_thread_notify execute:from frappe.desk.page.setup_wizard.install_fixtures import update_genders;update_genders() frappe.patches.v12_0.set_correct_url_in_files frappe.patches.v13_0.website_theme_custom_scss @@ -293,4 +294,4 @@ execute:frappe.delete_doc("DocType", "Onboarding Slide Help Link") frappe.patches.v13_0.update_date_filters_in_user_settings frappe.patches.v13_0.update_duration_options frappe.patches.v13_0.replace_old_data_import # 2020-06-24 -frappe.patches.v13_0.create_custom_dashboards_cards_and_charts \ No newline at end of file +frappe.patches.v13_0.create_custom_dashboards_cards_and_charts diff --git a/frappe/patches/v12_0/remove_example_email_thread_notify.py b/frappe/patches/v12_0/remove_example_email_thread_notify.py new file mode 100644 index 0000000000..94959b6077 --- /dev/null +++ b/frappe/patches/v12_0/remove_example_email_thread_notify.py @@ -0,0 +1,8 @@ +import frappe + + +def execute(): + # remove all example.com email user accounts from notifications + frappe.db.sql("""UPDATE `tabUser` + SET thread_notify=0, send_me_a_copy=0 + WHERE email like '%@example.com'""") diff --git a/frappe/utils/install.py b/frappe/utils/install.py index e5bf122d81..bb384fb300 100644 --- a/frappe/utils/install.py +++ b/frappe/utils/install.py @@ -50,11 +50,13 @@ def install_basic_docs(): install_docs = [ {'doctype':'User', 'name':'Administrator', 'first_name':'Administrator', 'email':'admin@example.com', 'enabled':1, "is_admin": 1, - 'roles': [{'role': 'Administrator'}] + 'roles': [{'role': 'Administrator'}], + 'thread_notify': 0, 'send_me_a_copy': 0 }, {'doctype':'User', 'name':'Guest', 'first_name':'Guest', 'email':'guest@example.com', 'enabled':1, "is_guest": 1, - 'roles': [{'role': 'Guest'}] + 'roles': [{'role': 'Guest'}], + 'thread_notify': 0, 'send_me_a_copy': 0 }, {'doctype': "Role", "role_name": "Report Manager"}, {'doctype': "Role", "role_name": "Translator"},