mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-12 03:15:07 +00:00
fix(email_campaign): prevent unsubscribing entire campaign when email group member unsubscribes
(cherry picked from commit 56f597f5ad)
This commit is contained in:
@@ -204,8 +204,22 @@ def send_mail(entry, email_campaign):
|
|||||||
|
|
||||||
# called from hooks on doc_event Email Unsubscribe
|
# called from hooks on doc_event Email Unsubscribe
|
||||||
def unsubscribe_recipient(unsubscribe, method):
|
def unsubscribe_recipient(unsubscribe, method):
|
||||||
if unsubscribe.reference_doctype == "Email Campaign":
|
if unsubscribe.reference_doctype != "Email Campaign":
|
||||||
frappe.db.set_value("Email Campaign", unsubscribe.reference_name, "status", "Unsubscribed")
|
return
|
||||||
|
|
||||||
|
email_campaign = frappe.get_doc("Email Campaign", unsubscribe.reference_name)
|
||||||
|
|
||||||
|
if email_campaign.email_campaign_for == "Email Group":
|
||||||
|
if unsubscribe.email:
|
||||||
|
frappe.db.set_value(
|
||||||
|
"Email Group Member",
|
||||||
|
{"email_group": email_campaign.recipient, "email": unsubscribe.email},
|
||||||
|
"unsubscribed",
|
||||||
|
1,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
# For Lead or Contact
|
||||||
|
frappe.db.set_value("Email Campaign", email_campaign.name, "status", "Unsubscribed")
|
||||||
|
|
||||||
|
|
||||||
# called through hooks to update email campaign status daily
|
# called through hooks to update email campaign status daily
|
||||||
|
|||||||
Reference in New Issue
Block a user