<commit_before>import frappe, json
from frappe.core.doctype.user.user import ask_pass_update, setup_user_email_inbox

def execute():
	""" 
		depricate email inbox page if exists
		remove desktop icon for email inbox page if exists
		patch to remove Custom DocPerm for communication
	"""

	if frappe.db.exists("Page", "email_inbox"):
		frappe.delete_doc("Page", "email_inbox")

	desktop_icon = frappe.db.get_value("Desktop Icon", {
		"module_name": "Email",
		"type": "Page",
		"link": "email_inbox"
	})

	if desktop_icon:
		frappe.delete_doc("Desktop Icon", desktop_icon)

	frappe.db.sql("""update `tabCustom DocPerm` set `write`=0, email=1 where parent='Communication'""")

	setup_inbox_from_email_account()

def setup_inbox_from_email_account():
	""" add user inbox child table entry for existing email account in not exists """

	frappe.reload_doc("core", "doctype", "user_email")

	email_accounts = frappe.get_all("Email Account", filters={"enable_incoming": 1},
		fields=["name", "email_id", "awaiting_password", "enable_outgoing"])

	for email_account in email_accounts:
		setup_user_email_inbox(email_account.get("name"), email_account.get("awaiting_password"),
			email_account.get("email_id"), email_account.get("enabled_outgoing"))<commit_msg>[patch] fixes in setup email inbox patch<commit_after>import frappe, json
from frappe.core.doctype.user.user import ask_pass_update, setup_user_email_inbox

def execute():
	""" 
		depricate email inbox page if exists
		remove desktop icon for email inbox page if exists
		patch to remove Custom DocPerm for communication
	"""

	if frappe.db.exists("Page", "email_inbox"):
		frappe.delete_doc("Page", "email_inbox")

	desktop_icon = frappe.db.get_value("Desktop Icon", {
		"module_name": "Email",
		"type": "Page",
		"link": "email_inbox"
	})

	if desktop_icon:
		frappe.delete_doc("Desktop Icon", desktop_icon)

	frappe.db.sql("""update `tabCustom DocPerm` set `write`=0, email=1 where parent='Communication'""")

	setup_inbox_from_email_account()

def setup_inbox_from_email_account():
	""" add user inbox child table entry for existing email account in not exists """

	frappe.reload_doc("core", "doctype", "user_email")
	frappe.reload_doc("email", "doctype", "email_account")

	email_accounts = frappe.get_all("Email Account", filters={"enable_incoming": 1},
		fields=["name", "email_id", "awaiting_password", "enable_outgoing"])

	for email_account in email_accounts:
		setup_user_email_inbox(email_account.get("name"), email_account.get("awaiting_password"),
			email_account.get("email_id"), email_account.get("enabled_outgoing"))
{'fraction_non_alphanumeric': 0.1332560834298957, 'fraction_numerical': 0.002317497103128621, 'mean_word_length': 6.52906976744186, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3734591', 'n_tokens_mistral': 908, 'n_tokens_neox': 866, 'n_words': 198}