mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 14:35:27 +00:00
Add Email Mirror default settings and error out with readable warning if not configured
(imported from commit adac321d09561b51277ec1e314a1d480dc01e0c8)
This commit is contained in:
@@ -27,7 +27,7 @@ from django.core.management.base import BaseCommand
|
|||||||
|
|
||||||
from zerver.lib.actions import decode_email_address
|
from zerver.lib.actions import decode_email_address
|
||||||
from zerver.lib.upload import upload_message_image
|
from zerver.lib.upload import upload_message_image
|
||||||
from zerver.models import Stream, get_user_profile_by_email
|
from zerver.models import Stream, get_user_profile_by_email, UserProfile
|
||||||
|
|
||||||
from twisted.internet import protocol, reactor, ssl
|
from twisted.internet import protocol, reactor, ssl
|
||||||
from twisted.mail import imap4
|
from twisted.mail import imap4
|
||||||
@@ -50,8 +50,14 @@ logger = logging.getLogger(__name__)
|
|||||||
logger.setLevel(logging.DEBUG)
|
logger.setLevel(logging.DEBUG)
|
||||||
logger.addHandler(file_handler)
|
logger.addHandler(file_handler)
|
||||||
|
|
||||||
email_gateway_user = get_user_profile_by_email(settings.EMAIL_GATEWAY_BOT_ZULIP_USER)
|
email_gateway_user = None
|
||||||
api_key = email_gateway_user.api_key
|
api_key = None
|
||||||
|
try:
|
||||||
|
email_gateway_user = get_user_profile_by_email(settings.EMAIL_GATEWAY_BOT_ZULIP_USER)
|
||||||
|
api_key = email_gateway_user.api_key
|
||||||
|
except UserProfile.DoesNotExist:
|
||||||
|
print "No configured %s user" % (settings.EMAIL_GATEWAY_BOT_ZULIP_USER,)
|
||||||
|
|
||||||
|
|
||||||
if settings.DEPLOYED:
|
if settings.DEPLOYED:
|
||||||
staging_api_client = zulip.Client(
|
staging_api_client = zulip.Client(
|
||||||
@@ -305,5 +311,12 @@ Run this command out of a cron job.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def handle(self, **options):
|
def handle(self, **options):
|
||||||
|
if (not settings.EMAIL_GATEWAY_BOT_ZULIP_USER or not settings.EMAIL_GATEWAY_LOGIN or
|
||||||
|
not settings.EMAIL_GATEWAY_PASSWORD or not settings.EMAIL_GATEWAY_IMAP_SERVER or
|
||||||
|
not settings.EMAIL_GATEWAY_IMAP_PORT or not settings.EMAIL_GATEWAY_IMAP_FOLDER or
|
||||||
|
not email_gateway_user):
|
||||||
|
print "Please configure the Email Mirror Gateway in your local_settings.py"
|
||||||
|
exit(1)
|
||||||
|
|
||||||
reactor.callLater(0, main)
|
reactor.callLater(0, main)
|
||||||
reactor.run()
|
reactor.run()
|
||||||
|
|||||||
@@ -202,7 +202,13 @@ DEFAULT_SETTINGS = {'TWITTER_CONSUMER_KEY': '',
|
|||||||
'TWITTER_CONSUMER_SECRET': '',
|
'TWITTER_CONSUMER_SECRET': '',
|
||||||
'TWITTER_ACCESS_TOKEN_KEY': '',
|
'TWITTER_ACCESS_TOKEN_KEY': '',
|
||||||
'TWITTER_ACCESS_TOKEN_SECRET': '',
|
'TWITTER_ACCESS_TOKEN_SECRET': '',
|
||||||
'EMBEDLY_KEY': ''}
|
'EMBEDLY_KEY': '',
|
||||||
|
'EMAIL_GATEWAY_BOT_ZULIP_USER': None,
|
||||||
|
'EMAIL_GATEWAY_LOGIN': None,
|
||||||
|
'EMAIL_GATEWAY_PASSWORD': None,
|
||||||
|
'EMAIL_GATEWAY_IMAP_SERVER': None,
|
||||||
|
'EMAIL_GATEWAY_IMAP_PORT': None,
|
||||||
|
'EMAIL_GATEWAY_IMAP_FOLDER': None}
|
||||||
|
|
||||||
for setting_name, setting_val in DEFAULT_SETTINGS.iteritems():
|
for setting_name, setting_val in DEFAULT_SETTINGS.iteritems():
|
||||||
if not setting_name in vars():
|
if not setting_name in vars():
|
||||||
|
|||||||
Reference in New Issue
Block a user