Merge pull request #11253 from saurabh6790/email-formatting-patch

fix: email formatting in communication and email queue
This commit is contained in:
mergify[bot] 2020-09-01 08:46:24 +00:00 committed by GitHub
commit 6da3036181
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 45 additions and 0 deletions

View file

@ -301,6 +301,7 @@ frappe.patches.v13_0.rename_is_custom_field_in_dashboard_chart
frappe.patches.v13_0.add_standard_navbar_items
frappe.patches.v13_0.generate_theme_files_in_public_folder
frappe.patches.v13_0.increase_password_length
frappe.patches.v12_0.fix_email_id_formatting
frappe.patches.v13_0.add_toggle_width_in_navbar_settings
frappe.patches.v13_0.rename_notification_fields
frappe.patches.v13_0.remove_duplicate_navbar_items

View file

@ -0,0 +1,44 @@
import frappe
def execute():
fix_communications()
fix_show_as_cc_email_queue()
fix_email_queue_recipients()
def fix_communications():
for communication in frappe.db.sql('''select name, recipients, cc, bcc from tabCommunication
where creation > '2020-06-01'
and communication_medium='Email'
and communication_type='Communication'
and (cc like '%<%' or bcc like '%<%' or recipients like '%<%')
''', as_dict=1):
communication['recipients'] = format_email_id(communication.recipients)
communication['cc'] = format_email_id(communication.cc)
communication['bcc'] = format_email_id(communication.bcc)
frappe.db.sql('''update `tabCommunication` set recipients=%s,cc=%s,bcc=%s
where name =%s ''', (communication['recipients'], communication['cc'],
communication['bcc'], communication['name']))
def fix_show_as_cc_email_queue():
for queue in frappe.get_all("Email Queue", {'creation': ['>', '2020-06-01'],
'status': 'Not Sent', 'show_as_cc': ['like', '%<%']},
['name', 'show_as_cc']):
frappe.db.set_value('Email Queue', queue['name'],
'show_as_cc', format_email_id(queue['show_as_cc']))
def fix_email_queue_recipients():
for recipient in frappe.db.sql('''select recipient, name from
`tabEmail Queue Recipient` where recipient like '%<%'
and status='Not Sent' and creation > '2020-06-01' ''', as_dict=1):
frappe.db.set_value('Email Queue Recipient', recipient['name'],
'recipient', format_email_id(recipient['recipient']))
def format_email_id(email):
if email and ('<' in email and '>' in email):
return email.replace('&gt;', '>').replace('&lt;', '<')
return email