2013-04-23 18:51:17 +02:00
|
|
|
from __future__ import absolute_import
|
|
|
|
|
2013-04-08 18:27:07 +02:00
|
|
|
from django.core.management.base import BaseCommand
|
|
|
|
|
2013-07-29 23:03:31 +02:00
|
|
|
from zerver.models import get_user_profile_by_email, get_prereg_user_by_email
|
|
|
|
from zerver.lib.queue import SimpleQueueClient
|
|
|
|
from zerver.lib.actions import do_send_confirmation_email
|
2013-04-08 18:27:07 +02:00
|
|
|
|
|
|
|
class Command(BaseCommand):
|
|
|
|
"""
|
|
|
|
Send confirmation e-mails to invited users.
|
|
|
|
|
|
|
|
This command processes events from the `invites` queue.
|
|
|
|
"""
|
|
|
|
def subscribe(self, ch, method, properties, data):
|
|
|
|
invitee = get_prereg_user_by_email(data["email"])
|
|
|
|
referrer = get_user_profile_by_email(data["referrer_email"])
|
|
|
|
do_send_confirmation_email(invitee, referrer)
|
|
|
|
|
|
|
|
def handle(self, *args, **options):
|
|
|
|
q = SimpleQueueClient()
|
|
|
|
q.register_json_consumer("invites", self.subscribe)
|
|
|
|
q.start_consuming()
|