From fb8bd57ec1c96ad3b3eb98c85eb4cfa7318320e4 Mon Sep 17 00:00:00 2001 From: Vishnu Ks Date: Mon, 17 Jul 2017 18:55:32 +0000 Subject: [PATCH] models: Create get_user_including_cross_realm function. --- zerver/models.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/zerver/models.py b/zerver/models.py index 775feecae1..c7d7b1f9e1 100644 --- a/zerver/models.py +++ b/zerver/models.py @@ -1417,6 +1417,13 @@ def get_user(email, realm): # type: (Text, Realm) -> UserProfile return UserProfile.objects.select_related().get(email__iexact=email.strip(), realm=realm) +def get_user_including_cross_realm(email, realm=None): + # type: (Text, Optional[Realm]) -> UserProfile + if email in get_cross_realm_emails(): + return get_system_bot(email) + assert realm is not None + return get_user(email, realm) + @cache_with_key(bot_profile_cache_key, timeout=3600*24*7) def get_system_bot(email): # type: (Text) -> UserProfile