mirror of
https://github.com/zulip/zulip.git
synced 2025-11-13 18:36:36 +00:00
[manual] Push new users' data to MailChimp.
This creates a new management command, subscribe_new_users, which should be run as a daemon process. When new users are created, an event is passed to RabbitMQ including the following data: * Email * Full name * IP address of the person who confirmed registration * Time of registration confirmation MailChimp strongly encourages the collection of the last two to enable responses to abuse requests, and providing more data lowers the chance that we could get banned from their service if complaints do occur. To use this commit, you need to install the "postmonkey" module from PyPI. (imported from commit 20c628c3fa8bb985aaead85a80ad3b38bf94b9dc)
This commit is contained in:
@@ -426,6 +426,9 @@ OPENID_SSO_SERVER_URL = 'https://www.google.com/accounts/o8/id'
|
||||
OPENID_CREATE_USERS = True
|
||||
OPENID_RENDER_FAILURE = openid_failure_handler
|
||||
|
||||
MAILCHIMP_API_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-us4'
|
||||
HUMBUG_FRIENDS_LIST_ID = '84b2f3da6b'
|
||||
|
||||
EVENT_LOG_DIR = 'event_log'
|
||||
|
||||
# Client-side polling timeout for get_events, in milliseconds.
|
||||
|
||||
22
zephyr/management/commands/subscribe_new_users.py
Normal file
22
zephyr/management/commands/subscribe_new_users.py
Normal file
@@ -0,0 +1,22 @@
|
||||
import simplejson
|
||||
from postmonkey import PostMonkey
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.conf import settings
|
||||
|
||||
from zephyr.lib.queue import SimpleQueueClient
|
||||
|
||||
class Command(BaseCommand):
|
||||
pm = PostMonkey(settings.MAILCHIMP_API_KEY, timeout=10)
|
||||
|
||||
def subscribe(self, ch, method, properties, data):
|
||||
self.pm.listSubscribe(
|
||||
id=settings.HUMBUG_FRIENDS_LIST_ID,
|
||||
email_address=data['EMAIL'],
|
||||
merge_vars=data['merge_vars'],
|
||||
double_optin=False,
|
||||
send_welcome=False)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
q = SimpleQueueClient()
|
||||
q.register_json_consumer("signups", self.subscribe)
|
||||
q.start_consuming()
|
||||
@@ -42,6 +42,7 @@ from zephyr.lib.response import json_success, json_error, json_response, json_me
|
||||
from zephyr.lib.timestamp import timestamp_to_datetime, datetime_to_timestamp
|
||||
from zephyr.lib.cache import cache_with_key
|
||||
from zephyr.lib.unminify import SourceMap
|
||||
from zephyr.lib.queue import queue_json_publish
|
||||
from zephyr import tornado_callbacks
|
||||
|
||||
from confirmation.models import Confirmation
|
||||
@@ -223,6 +224,17 @@ def accounts_register(request):
|
||||
)
|
||||
|
||||
notify_new_user(user_profile)
|
||||
queue_json_publish(
|
||||
"signups",
|
||||
{
|
||||
'EMAIL': email,
|
||||
'merge_vars': {
|
||||
'NAME': full_name,
|
||||
'OPTIN_IP': request.META['REMOTE_ADDR'],
|
||||
'OPTIN_TIME': datetime.datetime.isoformat(datetime.datetime.now()),
|
||||
},
|
||||
},
|
||||
lambda event: None)
|
||||
|
||||
login(request, authenticate(username=email, password=password))
|
||||
return HttpResponseRedirect(reverse('zephyr.views.home'))
|
||||
|
||||
Reference in New Issue
Block a user