views/presence: Refactor get_user_profile_by_email -> get_user.

This commit is contained in:
Tim Abbott
2017-05-22 16:43:08 -07:00
parent 7995dd2de6
commit accc7406da

View File

@@ -16,8 +16,7 @@ from zerver.lib.request import has_request_variables, REQ, JsonableError
from zerver.lib.response import json_success, json_error from zerver.lib.response import json_success, json_error
from zerver.lib.timestamp import datetime_to_timestamp from zerver.lib.timestamp import datetime_to_timestamp
from zerver.lib.validator import check_bool from zerver.lib.validator import check_bool
from zerver.models import UserActivity, UserPresence, UserProfile, \ from zerver.models import UserActivity, UserPresence, UserProfile, get_user
get_user_profile_by_email
def get_status_list(requesting_user_profile): def get_status_list(requesting_user_profile):
# type: (UserProfile) -> Dict[str, Any] # type: (UserProfile) -> Dict[str, Any]
@@ -27,11 +26,9 @@ def get_status_list(requesting_user_profile):
def get_presence_backend(request, user_profile, email): def get_presence_backend(request, user_profile, email):
# type: (HttpRequest, UserProfile, Text) -> HttpResponse # type: (HttpRequest, UserProfile, Text) -> HttpResponse
try: try:
target = get_user_profile_by_email(email) target = get_user(email, user_profile.realm)
except UserProfile.DoesNotExist: except UserProfile.DoesNotExist:
return json_error(_('No such user')) return json_error(_('No such user'))
if target.realm != user_profile.realm:
return json_error(_('No such user'))
if not target.is_active: if not target.is_active:
return json_error(_('No such user')) return json_error(_('No such user'))
if target.is_bot: if target.is_bot: