mirror of
https://github.com/zulip/zulip.git
synced 2025-11-07 07:23:22 +00:00
Cleanup guardian-based complexity in get_realm_user_dicts.
The old code for this lookup was unnecessarily complicated because we were working around Guardian, where the `is_realm_admin` check was extremely expensive.
This commit is contained in:
@@ -2426,11 +2426,8 @@ def get_status_dict(requesting_user_profile):
|
||||
|
||||
|
||||
def get_realm_user_dicts(user_profile):
|
||||
# Due to our permission model, it is advantageous to find the admin users in bulk.
|
||||
admins = user_profile.realm.get_admin_users()
|
||||
admin_emails = set([up.email for up in admins])
|
||||
return [{'email' : userdict['email'],
|
||||
'is_admin' : userdict['email'] in admin_emails,
|
||||
'is_admin' : userdict['is_realm_admin'],
|
||||
'is_bot' : userdict['is_bot'],
|
||||
'full_name' : userdict['full_name']}
|
||||
for userdict in get_active_user_dicts_in_realm(user_profile.realm)]
|
||||
|
||||
@@ -268,7 +268,7 @@ def cache_save_user_profile(user_profile):
|
||||
# type: (Any) -> None
|
||||
cache_set(user_profile_by_id_cache_key(user_profile.id), user_profile, timeout=3600*24*7)
|
||||
|
||||
active_user_dict_fields = ['id', 'full_name', 'short_name', 'email', 'is_bot']
|
||||
active_user_dict_fields = ['id', 'full_name', 'short_name', 'email', 'is_realm_admin', 'is_bot']
|
||||
def active_user_dicts_in_realm_cache_key(realm):
|
||||
# type: (Any) -> str
|
||||
return "active_user_dicts_in_realm:%s" % (realm.id,)
|
||||
|
||||
Reference in New Issue
Block a user