email_validation: Rename to validate_is_not_disposable.

This clarifies what we are asserting -- namely, that the email is
_not_ disposable.
This commit is contained in:
Alex Vandiver 2024-02-27 15:14:43 +00:00 committed by Tim Abbott
parent c1aadbe52e
commit 4b512b3409
2 changed files with 4 additions and 4 deletions

View File

@ -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

View File

@ -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."))