mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 14:35:27 +00:00
Fix clear_followup_emails_queue on Zulip Enterprise.
(imported from commit bf211b205bc39a08340306d06fbb76479a02ed9e)
This commit is contained in:
@@ -2104,7 +2104,7 @@ def get_emails_from_user_ids(user_ids):
|
|||||||
return UserProfile.emails_from_ids(user_ids)
|
return UserProfile.emails_from_ids(user_ids)
|
||||||
|
|
||||||
@uses_mandrill
|
@uses_mandrill
|
||||||
def clear_followup_emails_queue(email, from_email=None, mail_client=None):
|
def clear_followup_emails_queue(email, mail_client=None):
|
||||||
"""
|
"""
|
||||||
Clear out queued emails (from Mandrill's queue) that would otherwise
|
Clear out queued emails (from Mandrill's queue) that would otherwise
|
||||||
be sent to a specific email address. Optionally specify which sender
|
be sent to a specific email address. Optionally specify which sender
|
||||||
@@ -2118,16 +2118,11 @@ def clear_followup_emails_queue(email, from_email=None, mail_client=None):
|
|||||||
# Zulip Enterprise implementation
|
# Zulip Enterprise implementation
|
||||||
if not mail_client:
|
if not mail_client:
|
||||||
items = ScheduledJob.objects.filter(type=ScheduledJob.EMAIL, filter_string__iexact = email)
|
items = ScheduledJob.objects.filter(type=ScheduledJob.EMAIL, filter_string__iexact = email)
|
||||||
if from_email is not None:
|
|
||||||
items = [item for item in items
|
|
||||||
if ujson.loads(item.data).get('from_email').lower() == from_email.lower()]
|
|
||||||
items.delete()
|
items.delete()
|
||||||
return
|
return
|
||||||
|
|
||||||
# Mandrill implementation
|
# Mandrill implementation
|
||||||
for email in mail_client.messages.list_scheduled(to=email):
|
for email in mail_client.messages.list_scheduled(to=email):
|
||||||
if from_email is not None and email.get('from_email').lower() != from_email.lower():
|
|
||||||
continue
|
|
||||||
result = mail_client.messages.cancel_scheduled(id=email["_id"])
|
result = mail_client.messages.cancel_scheduled(id=email["_id"])
|
||||||
if result.get("status") == "error":
|
if result.get("status") == "error":
|
||||||
print result.get("name"), result.get("error")
|
print result.get("name"), result.get("error")
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ class SignupWorker(QueueProcessingWorker):
|
|||||||
def consume(self, data):
|
def consume(self, data):
|
||||||
merge_vars=data['merge_vars']
|
merge_vars=data['merge_vars']
|
||||||
# This should clear out any invitation reminder emails
|
# This should clear out any invitation reminder emails
|
||||||
clear_followup_emails_queue(data["EMAIL"], from_email="zulip@zulip.com")
|
clear_followup_emails_queue(data["EMAIL"])
|
||||||
if settings.MAILCHIMP_API_KEY != '' and settings.DEPLOYED:
|
if settings.MAILCHIMP_API_KEY != '' and settings.DEPLOYED:
|
||||||
try:
|
try:
|
||||||
self.pm.listSubscribe(
|
self.pm.listSubscribe(
|
||||||
|
|||||||
Reference in New Issue
Block a user