From cc2bb854841a1e13d43face6e32d97fab4d4f9bf Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Thu, 4 Jan 2024 15:53:59 +0530 Subject: [PATCH] fix: correct arg type assign_to expects a list of strings of users not a single string. --- frappe/email/doctype/email_account/email_account.py | 6 ++++-- frappe/tests/test_email.py | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/frappe/email/doctype/email_account/email_account.py b/frappe/email/doctype/email_account/email_account.py index f4d7cbf8a2..0fa328b42d 100755 --- a/frappe/email/doctype/email_account/email_account.py +++ b/frappe/email/doctype/email_account/email_account.py @@ -294,6 +294,8 @@ class EmailAccount(Document): error_message = _( "Authentication failed while receiving emails from Email Account: {0}." ).format(self.name) + + error_message = _("Email Account Disabled.") + " " + error_message error_message += "
" + _("Message from server: {0}").format(cstr(e)) self.handle_incoming_connect_error(description=error_message) return None @@ -489,7 +491,7 @@ class EmailAccount(Document): state.pop("_smtp_server_instance", None) def handle_incoming_connect_error(self, description): - if self.get_failed_attempts_count() > 2: + if self.get_failed_attempts_count() > 5: # This is done in background to avoid committing here. frappe.enqueue(self._disable_broken_incoming_account, description=description) else: @@ -502,7 +504,7 @@ class EmailAccount(Document): try: assign_to.add( { - "assign_to": user, + "assign_to": [user], "doctype": self.doctype, "name": self.name, "description": description, diff --git a/frappe/tests/test_email.py b/frappe/tests/test_email.py index 13f385a22d..bd17a523ba 100644 --- a/frappe/tests/test_email.py +++ b/frappe/tests/test_email.py @@ -361,8 +361,10 @@ class TestEmailIntegrationTest(FrappeTestCase): subject = "checking if email works" content = "is email working?" - frappe.sendmail(sender=sender, recipients=recipients, subject=subject, content=content, now=True) - email = frappe.get_last_doc("Email Queue") + email = frappe.sendmail( + sender=sender, recipients=recipients, subject=subject, content=content, now=True + ) + email.reload() self.assertEqual(email.sender, sender) self.assertEqual(len(email.recipients), 2) self.assertEqual(email.status, "Sent")