mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 22:13:26 +00:00
settings: Add FAKE_EMAIL_DOMAIN setting.
Fixes #9401. This adds a FAKE_EMAIL_DOMAIN setting, which should be used if EXTERNAL_HOST is not a valid domain, and something else is needed to form bot and dummy user emails (if email visibility is turned off). It defaults to EXTERNAL_HOST. get_fake_email_domain() should be used to get this value. It validates that it's correctly set - that it can be used to form valid emails. If it's not set correctly, an exception is raised. This is the right approach, because it's undesirable to have the server seemingly peacefully operating with that setting misconfigured, as that could mask some hidden sneaky bugs due to UserProfiles with invalid emails, which would blow up the moment some code that does validate the emails is called.
This commit is contained in:
committed by
Tim Abbott
parent
4de3bbeafa
commit
d70e1bcdb7
@@ -1,6 +1,7 @@
|
||||
from django.contrib.auth.models import UserManager
|
||||
from django.utils.timezone import now as timezone_now
|
||||
from zerver.models import UserProfile, Recipient, Subscription, Realm, Stream
|
||||
from zerver.models import UserProfile, Recipient, Subscription, Realm, Stream, \
|
||||
get_fake_email_domain
|
||||
from zerver.lib.upload import copy_avatar
|
||||
from zerver.lib.hotspots import copy_hotpots
|
||||
from zerver.lib.utils import generate_api_key
|
||||
@@ -32,8 +33,7 @@ def copy_user_settings(source_profile: UserProfile, target_profile: UserProfile)
|
||||
|
||||
def get_display_email_address(user_profile: UserProfile, realm: Realm) -> str:
|
||||
if realm.email_address_visibility != Realm.EMAIL_ADDRESS_VISIBILITY_EVERYONE:
|
||||
# TODO: realm.host isn't always a valid option here.
|
||||
return "user%s@%s" % (user_profile.id, realm.host.split(':')[0])
|
||||
return "user%s@%s" % (user_profile.id, get_fake_email_domain())
|
||||
return user_profile.delivery_email
|
||||
|
||||
# create_user_profile is based on Django's User.objects.create_user,
|
||||
|
||||
Reference in New Issue
Block a user