From 4b512b3409dcf470cc7319c1a36d98292bef6c62 Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Tue, 27 Feb 2024 15:14:43 +0000 Subject: [PATCH] email_validation: Rename to validate_is_not_disposable. This clarifies what we are asserting -- namely, that the email is _not_ disposable. --- zerver/lib/email_validation.py | 4 ++-- zilencer/views.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/zerver/lib/email_validation.py b/zerver/lib/email_validation.py index b8d418863c..31890dbfbd 100644 --- a/zerver/lib/email_validation.py +++ b/zerver/lib/email_validation.py @@ -17,7 +17,7 @@ from zerver.models.realms import ( from zerver.models.users import get_users_by_delivery_email, is_cross_realm_bot_email -def validate_disposable(email: str) -> None: +def validate_is_not_disposable(email: str) -> None: if is_disposable_domain(Address(addr_spec=email).domain): raise DisposableEmailError @@ -26,7 +26,7 @@ def get_realm_email_validator(realm: Realm) -> Callable[[str], None]: if not realm.emails_restricted_to_domains: # Should we also do '+' check for non-restricted realms? if realm.disallow_disposable_email_addresses: - return validate_disposable + return validate_is_not_disposable # allow any email through return lambda email: None diff --git a/zilencer/views.py b/zilencer/views.py index 209fd6f2f8..ebeb2714ef 100644 --- a/zilencer/views.py +++ b/zilencer/views.py @@ -38,7 +38,7 @@ from corporate.models import ( get_customer_by_remote_realm, ) from zerver.decorator import require_post -from zerver.lib.email_validation import validate_disposable +from zerver.lib.email_validation import validate_is_not_disposable from zerver.lib.exceptions import ( ErrorCode, JsonableError, @@ -143,7 +143,7 @@ def register_remote_server( # We don't want to allow disposable domains for contact_email either try: - validate_disposable(contact_email) + validate_is_not_disposable(contact_email) except DisposableEmailError: raise JsonableError(_("Please use your real email address."))