From e7a0135966e83ddae85a3158149e0e20747ca640 Mon Sep 17 00:00:00 2001 From: Sagar Vora Date: Wed, 13 Sep 2023 21:28:20 +0530 Subject: [PATCH] example usage --- frappe/core/doctype/communication/email.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/frappe/core/doctype/communication/email.py b/frappe/core/doctype/communication/email.py index 219568f7a689..5cb7bc668e7c 100755 --- a/frappe/core/doctype/communication/email.py +++ b/frappe/core/doctype/communication/email.py @@ -258,15 +258,17 @@ def add_attachments(name: str, attachments: Iterable[str | dict]) -> None: @frappe.whitelist(allow_guest=True, methods=("GET",)) def mark_email_as_seen(name: str = None): + frappe.request.after_response.add(lambda: _mark_email_as_seen(name)) + frappe.response.update(frappe.utils.get_imaginary_pixel_response()) + + +def _mark_email_as_seen(name): try: update_communication_as_read(name) - frappe.db.commit() # nosemgrep: this will be called in a GET request - except Exception: frappe.log_error("Unable to mark as seen", None, "Communication", name) - finally: - frappe.response.update(frappe.utils.get_imaginary_pixel_response()) + frappe.db.commit() # nosemgrep: after_response requires explicit commit def update_communication_as_read(name):