From 151a95aa30b1def11bc5e49b0a770ed1d889118c Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Mon, 4 Apr 2022 17:11:14 +0530 Subject: [PATCH] fix: remove spaces from email placeholders spaces get converted to %20 which breaks text replacement --- frappe/email/doctype/email_queue/email_queue.py | 6 +++--- frappe/email/queue.py | 10 +++++----- frappe/templates/emails/email_footer.html | 2 +- frappe/tests/test_email.py | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/frappe/email/doctype/email_queue/email_queue.py b/frappe/email/doctype/email_queue/email_queue.py index dd8623cae2..9003158a85 100644 --- a/frappe/email/doctype/email_queue/email_queue.py +++ b/frappe/email/doctype/email_queue/email_queue.py @@ -220,9 +220,9 @@ class SendMailContext: def message_placeholder(self, placeholder_key): map = { - 'tracker': '', - 'unsubscribe_url': '', - 'cc': '', + 'tracker': '', + 'unsubscribe_url': '', + 'cc': '', 'recipient': '', } return map.get(placeholder_key) diff --git a/frappe/email/queue.py b/frappe/email/queue.py index f6f52e79e2..07a9c6552d 100755 --- a/frappe/email/queue.py +++ b/frappe/email/queue.py @@ -66,25 +66,25 @@ def get_emails_sent_today(email_account=None): def get_unsubscribe_message(unsubscribe_message, expose_recipients): if unsubscribe_message: - unsubscribe_html = '''{0}'''.format(unsubscribe_message) else: - unsubscribe_link = '''{0}'''.format(_('Unsubscribe')) unsubscribe_html = _("{0} to stop receiving emails of this type").format(unsubscribe_link) html = """
- +
{0}
""".format(unsubscribe_html) if expose_recipients == "footer": - text = "\n" + text = "\n" else: text = "" - text += "\n\n{unsubscribe_message}: \n".format(unsubscribe_message=unsubscribe_message) + text += "\n\n{unsubscribe_message}: \n".format(unsubscribe_message=unsubscribe_message) return frappe._dict({ "html": html, diff --git a/frappe/templates/emails/email_footer.html b/frappe/templates/emails/email_footer.html index da6cab5f35..f66bf7cb99 100644 --- a/frappe/templates/emails/email_footer.html +++ b/frappe/templates/emails/email_footer.html @@ -18,7 +18,7 @@
- +
diff --git a/frappe/tests/test_email.py b/frappe/tests/test_email.py index 51a0786c2f..e4a18c06e5 100644 --- a/frappe/tests/test_email.py +++ b/frappe/tests/test_email.py @@ -27,7 +27,7 @@ class TestEmail(unittest.TestCase): self.assertTrue('test@example.com' in queue_recipients) self.assertTrue('test1@example.com' in queue_recipients) self.assertEqual(len(queue_recipients), 2) - self.assertTrue('' in email_queue[0]['message']) + self.assertTrue('' in email_queue[0]['message']) def test_send_after(self): self.test_email_queue(send_after=1)