mirror of https://github.com/zulip/zulip.git
Factor welcome e-mail enqueuing into its own function.
(imported from commit 85054ee3e567d2ba7a4ed94c52a311d02f5e4d43)
This commit is contained in:
parent
8e72084fcb
commit
2ba9415178
|
@ -2262,6 +2262,38 @@ def send_local_email_template_with_delay(recipients, template_prefix,
|
|||
sender=sender,
|
||||
tags=tags)
|
||||
|
||||
def enqueue_welcome_emails(email, name):
|
||||
sender = {'email': 'wdaher@zulip.com', 'name': 'Waseem Daher'}
|
||||
if settings.ENTERPRISE:
|
||||
sender = {'email': settings.ZULIP_ADMINISTRATOR, 'name': 'Zulip'}
|
||||
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
unsubscribe_link = one_click_unsubscribe_link(user_profile, "welcome")
|
||||
|
||||
template_payload = {'name': name,
|
||||
'not_enterprise': not settings.ENTERPRISE,
|
||||
'external_host': settings.EXTERNAL_HOST,
|
||||
'unsubscribe_link': unsubscribe_link}
|
||||
|
||||
#Send day 1 email
|
||||
send_local_email_template_with_delay([{'email': email, 'name': name}],
|
||||
"zerver/emails/followup/day1",
|
||||
template_payload,
|
||||
datetime.timedelta(hours=1),
|
||||
tags=["followup-emails"],
|
||||
sender=sender)
|
||||
#Send day 2 email
|
||||
tomorrow = datetime.datetime.utcnow() + datetime.timedelta(hours=24)
|
||||
# 11 AM EDT
|
||||
tomorrow_morning = datetime.datetime(tomorrow.year, tomorrow.month, tomorrow.day, 15, 0)
|
||||
assert(datetime.datetime.utcnow() < tomorrow_morning)
|
||||
send_local_email_template_with_delay([{'email': email, 'name': name}],
|
||||
"zerver/emails/followup/day2",
|
||||
template_payload,
|
||||
tomorrow_morning - datetime.datetime.utcnow(),
|
||||
tags=["followup-emails"],
|
||||
sender=sender)
|
||||
|
||||
def realm_aliases(realm):
|
||||
return [alias.domain for alias in realm.realmalias_set.all()]
|
||||
|
||||
|
|
|
@ -12,7 +12,8 @@ from zerver.lib.timestamp import timestamp_to_datetime
|
|||
from zerver.lib.actions import handle_missedmessage_emails, do_send_confirmation_email, \
|
||||
do_update_user_activity, do_update_user_activity_interval, do_update_user_presence, \
|
||||
internal_send_message, send_local_email_template_with_delay, clear_followup_emails_queue, \
|
||||
check_send_message, extract_recipients, one_click_unsubscribe_link
|
||||
check_send_message, extract_recipients, one_click_unsubscribe_link, \
|
||||
enqueue_welcome_emails
|
||||
from zerver.lib.digest import handle_digest_email
|
||||
from zerver.decorator import JsonableError
|
||||
from zerver.lib.socket import req_redis_key
|
||||
|
@ -86,8 +87,6 @@ class SignupWorker(QueueProcessingWorker):
|
|||
if settings.MAILCHIMP_API_KEY != '':
|
||||
self.pm = PostMonkey(settings.MAILCHIMP_API_KEY, timeout=10)
|
||||
|
||||
# Changes to this should also be reflected in
|
||||
# zerver/management/commands/enqueue_followup_emails.py:queue()
|
||||
def consume(self, data):
|
||||
merge_vars=data['merge_vars']
|
||||
# This should clear out any invitation reminder emails
|
||||
|
@ -105,40 +104,10 @@ class SignupWorker(QueueProcessingWorker):
|
|||
logging.warning("Attempted to sign up already existing email to list: %s" % (data['EMAIL'],))
|
||||
else:
|
||||
raise e
|
||||
|
||||
email = data.get("EMAIL")
|
||||
name = merge_vars.get("NAME")
|
||||
|
||||
|
||||
sender = {'email': 'wdaher@zulip.com', 'name': 'Waseem Daher'}
|
||||
if settings.ENTERPRISE:
|
||||
sender = {'email': settings.ZULIP_ADMINISTRATOR, 'name': 'Zulip'}
|
||||
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
unsubscribe_link = one_click_unsubscribe_link(user_profile, "welcome")
|
||||
|
||||
template_payload = {'name': name,
|
||||
'not_enterprise': not settings.ENTERPRISE,
|
||||
'external_host': settings.EXTERNAL_HOST,
|
||||
'unsubscribe_link': unsubscribe_link}
|
||||
|
||||
#Send day 1 email
|
||||
send_local_email_template_with_delay([{'email': email, 'name': name}],
|
||||
"zerver/emails/followup/day1",
|
||||
template_payload,
|
||||
datetime.timedelta(hours=1),
|
||||
tags=["followup-emails"],
|
||||
sender=sender)
|
||||
#Send day 2 email
|
||||
tomorrow = datetime.datetime.utcnow() + datetime.timedelta(hours=24)
|
||||
# 11 AM EDT
|
||||
tomorrow_morning = datetime.datetime(tomorrow.year, tomorrow.month, tomorrow.day, 15, 0)
|
||||
assert(datetime.datetime.utcnow() < tomorrow_morning)
|
||||
send_local_email_template_with_delay([{'email': email, 'name': name}],
|
||||
"zerver/emails/followup/day2",
|
||||
template_payload,
|
||||
tomorrow_morning - datetime.datetime.utcnow(),
|
||||
tags=["followup-emails"],
|
||||
sender=sender)
|
||||
enqueue_welcome_emails(email, name)
|
||||
|
||||
@assign_queue('invites')
|
||||
class ConfirmationEmailWorker(QueueProcessingWorker):
|
||||
|
|
Loading…
Reference in New Issue