settings: Change all uses of ZULIP_ADMINISTRATOR to FromAddress.SUPPORT.

Make it less likely that further development will break compatibility with
ZULIP_ADMINISTRATORs of the form "name <email>".

Note that the suggested value for this setting has been
'zulip-admin@example.com' for a while, so hopefully this commit causes no
change for most installations.
This commit is contained in:
Rishi Gupta 2017-07-01 20:27:01 -07:00 committed by Tim Abbott
parent 1291ac9eff
commit a26703109e
5 changed files with 12 additions and 8 deletions

View File

@ -15,6 +15,7 @@ from zproject.backends import (
AUTH_BACKEND_NAME_MAP
)
from zerver.lib.bugdown import convert
from zerver.lib.send_email import FromAddress
from zerver.lib.utils import get_subdomain
from zerver.lib.realm_icon import get_realm_icon_url
@ -111,7 +112,7 @@ def zulip_default_context(request):
'any_oauth_backend_enabled': any_oauth_backend_enabled(realm),
'no_auth_enabled': not auth_enabled_helper(list(AUTH_BACKEND_NAME_MAP.keys()), realm),
'development_environment': settings.DEVELOPMENT,
'support_email': settings.ZULIP_ADMINISTRATOR,
'support_email': FromAddress.SUPPORT,
'find_team_link_disabled': find_team_link_disabled,
'password_min_length': settings.PASSWORD_MIN_LENGTH,
'password_min_quality': settings.PASSWORD_MIN_ZXCVBN_QUALITY,

View File

@ -14,7 +14,7 @@ from jinja2 import Markup as mark_safe
from zerver.lib.actions import do_change_password, is_inactive, user_email_is_unique
from zerver.lib.name_restrictions import is_reserved_subdomain, is_disposable_domain
from zerver.lib.request import JsonableError
from zerver.lib.send_email import send_email
from zerver.lib.send_email import send_email, FromAddress
from zerver.lib.users import check_full_name
from zerver.lib.utils import get_subdomain, check_subdomain
from zerver.models import Realm, get_user_profile_by_email, UserProfile, \
@ -34,7 +34,7 @@ MIT_VALIDATION_ERROR = u'That user does not exist at MIT or is a ' + \
u'<a href="mailto:support@zulipchat.com">contact us</a>.'
WRONG_SUBDOMAIN_ERROR = "Your Zulip account is not a member of the " + \
"organization associated with this subdomain. " + \
"Please contact %s with any questions!" % (settings.ZULIP_ADMINISTRATOR,)
"Please contact %s with any questions!" % (FromAddress.SUPPORT,)
def email_is_not_mit_mailing_list(email):
# type: (Text) -> None
@ -253,13 +253,13 @@ class OurAuthenticationForm(AuthenticationForm):
Please contact %s to reactivate this group.""" % (
user_profile.realm.name,
settings.ZULIP_ADMINISTRATOR)
FromAddress.SUPPORT)
raise ValidationError(mark_safe(error_msg))
if not user_profile.is_active:
error_msg = (u"Sorry for the trouble, but your account has been "
u"deactivated. Please contact %s to reactivate "
u"it.") % (settings.ZULIP_ADMINISTRATOR,)
u"it.") % (FromAddress.SUPPORT,)
raise ValidationError(mark_safe(error_msg))
if not check_subdomain(get_subdomain(self.request), user_profile.realm.subdomain):

View File

@ -5,6 +5,7 @@ from django.core.mail import EmailMessage
from typing import Any, Mapping, Optional, Text
from zerver.lib.actions import internal_send_message
from zerver.lib.send_email import FromAddress
from zerver.lib.redis_utils import get_redis_client
from zerver.models import get_realm, get_system_bot, \
UserProfile, Realm
@ -75,7 +76,7 @@ def handle_feedback(event):
to_email = settings.FEEDBACK_EMAIL
subject = "Zulip feedback from %s" % (event["sender_email"],)
content = event["content"]
from_email = '"%s" <%s>' % (event["sender_full_name"], settings.ZULIP_ADMINISTRATOR)
from_email = '"%s" <%s>' % (event["sender_full_name"], FromAddress.SUPPORT)
headers = {'Reply-To': '"%s" <%s>' % (event["sender_full_name"], event["sender_email"])}
msg = EmailMessage(subject, content, from_email, [to_email], headers=headers)
msg.send()

View File

@ -25,7 +25,7 @@ def build_email(template_prefix, to_email, from_name=None, from_address=None,
reply_to_email=None, context={}):
# type: (str, Text, Optional[Text], Optional[Text], Optional[Text], Dict[str, Any]) -> EmailMultiAlternatives
context.update({
'support_email': settings.ZULIP_ADMINISTRATOR,
'support_email': FromAddress.SUPPORT,
'verbose_support_offers': settings.VERBOSE_SUPPORT_OFFERS,
})
subject = loader.render_to_string(template_prefix + '.subject',

View File

@ -6,6 +6,8 @@ from django.conf import settings
from django.core.mail import mail_admins, mail_managers, send_mail
from django.core.management.commands import sendtestemail
from zerver.lib.send_email import FromAddress
class Command(sendtestemail.Command):
def handle(self, *args, **kwargs):
# type: (*Any, **str) -> None
@ -13,7 +15,7 @@ class Command(sendtestemail.Command):
message = ("Success! If you receive this message, you've "
"successfully configured sending email from your "
"Zulip server.")
sender = settings.ZULIP_ADMINISTRATOR
sender = FromAddress.SUPPORT
send_mail(subject, message, sender, kwargs['email'])
if kwargs['managers']: