mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 22:43:42 +00:00
Move user_profiles_from_unvalidated_emails -> addressee.py.
This will avoid circular dependencies.
This commit is contained in:
@@ -15,7 +15,10 @@ from zerver.lib.bugdown import (
|
||||
version as bugdown_version,
|
||||
url_embed_preview_enabled_for_realm
|
||||
)
|
||||
from zerver.lib.addressee import Addressee
|
||||
from zerver.lib.addressee import (
|
||||
Addressee,
|
||||
user_profiles_from_unvalidated_emails,
|
||||
)
|
||||
from zerver.lib.cache import (
|
||||
delete_user_profile_caches,
|
||||
to_dict_cache_key,
|
||||
@@ -1172,17 +1175,6 @@ def recipient_for_emails(emails, not_forged_mirror_message,
|
||||
sender=sender
|
||||
)
|
||||
|
||||
def user_profiles_from_unvalidated_emails(emails):
|
||||
# type: (Iterable[Text]) -> List[UserProfile]
|
||||
user_profiles = [] # type: List[UserProfile]
|
||||
for email in emails:
|
||||
try:
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
except UserProfile.DoesNotExist:
|
||||
raise ValidationError(_("Invalid email '%s'") % (email,))
|
||||
user_profiles.append(user_profile)
|
||||
return user_profiles
|
||||
|
||||
def recipient_for_user_profiles(user_profiles, not_forged_mirror_message,
|
||||
forwarder_user_profile, sender):
|
||||
# type: (List[UserProfile], bool, Optional[UserProfile], UserProfile) -> Recipient
|
||||
|
||||
@@ -1,10 +1,26 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import print_function
|
||||
|
||||
from typing import Optional, Sequence, Text
|
||||
from typing import Iterable, List, Optional, Sequence, Text
|
||||
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.utils.translation import ugettext as _
|
||||
from zerver.lib.request import JsonableError
|
||||
from zerver.models import (
|
||||
UserProfile,
|
||||
get_user_profile_by_email,
|
||||
)
|
||||
|
||||
def user_profiles_from_unvalidated_emails(emails):
|
||||
# type: (Iterable[Text]) -> List[UserProfile]
|
||||
user_profiles = [] # type: List[UserProfile]
|
||||
for email in emails:
|
||||
try:
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
except UserProfile.DoesNotExist:
|
||||
raise ValidationError(_("Invalid email '%s'") % (email,))
|
||||
user_profiles.append(user_profile)
|
||||
return user_profiles
|
||||
|
||||
class Addressee(object):
|
||||
# This is really just a holder for vars that tended to be passed
|
||||
|
||||
Reference in New Issue
Block a user