diff --git a/static/js/activity.js b/static/js/activity.js index 8a0e6a74f0..e3ce75099a 100644 --- a/static/js/activity.js +++ b/static/js/activity.js @@ -216,8 +216,8 @@ function filter_and_sort(users) { exports._filter_and_sort = filter_and_sort; exports.update_users = function (user_list) { - if (page_params.domain === 'mit.edu') { - return; // MIT realm doesn't have a presence list + if (page_params.presence_disabled) { + return; } var users = exports.presence_info; @@ -278,8 +278,8 @@ function actually_update_users_for_search() { var update_users_for_search = _.throttle(actually_update_users_for_search, 50); exports.update_huddles = function () { - if (page_params.domain === 'mit.edu') { - return; // MIT realm doesn't have a presence list + if (page_params.presence_disabled) { + return; } var section = $('#group-pm-list').expectOne(); diff --git a/static/js/ui.js b/static/js/ui.js index 870719566b..7f38e6099c 100644 --- a/static/js/ui.js +++ b/static/js/ui.js @@ -488,8 +488,7 @@ $(function () { $("#edit-message-hotkey-help").hide(); } - // Some MIT-specific customizations - if (page_params.domain === 'mit.edu') { + if (page_params.presence_disabled) { $("#user-list").hide(); $("#group-pm-list").hide(); } diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py index f492a6401b..10a841a347 100644 --- a/zerver/lib/actions.py +++ b/zerver/lib/actions.py @@ -2653,7 +2653,7 @@ def gather_subscriptions(user_profile): def get_status_dict(requesting_user_profile): # type: (UserProfile) -> Dict[text_type, Dict[text_type, Dict[str, Any]]] # Return no status info for MIT - if requesting_user_profile.realm.domain == 'mit.edu': + if requesting_user_profile.realm.presence_disabled: return defaultdict(dict) return UserPresence.get_status_dict_by_realm(requesting_user_profile.realm_id) diff --git a/zerver/models.py b/zerver/models.py index 4e8bc2b34b..8f84238c6a 100644 --- a/zerver/models.py +++ b/zerver/models.py @@ -188,6 +188,11 @@ class Realm(ModelReprMixin, models.Model): # TODO: Change return type to QuerySet[UserProfile] return UserProfile.objects.filter(realm=self, is_active=True).select_related() + @property + def presence_disabled(self): + # type: () -> bool + return self.domain == "mit.edu" + class Meta(object): permissions = ( ('administer', "Administer a realm"), diff --git a/zerver/tests/tests.py b/zerver/tests/tests.py index 0d3b42d667..4504e8700e 100644 --- a/zerver/tests/tests.py +++ b/zerver/tests/tests.py @@ -1525,7 +1525,7 @@ class UserPresenceTests(AuthedTestCase): def test_no_mit(self): # type: () -> None - """MIT never gets a list of users""" + """Zephyr mirror realms such as MIT never get a list of users""" self.login("espuser@mit.edu") result = self.client.post("/json/users/me/presence", {'status': 'idle'}) self.assert_json_success(result) @@ -1796,6 +1796,7 @@ class HomeTest(AuthedTestCase): "password_auth_enabled", "people_list", "poll_timeout", + "presence_disabled", "product_name", "prompt_for_invites", "realm_allow_message_editing", diff --git a/zerver/views/__init__.py b/zerver/views/__init__.py index 5d5cad80ff..8a0bad8fb4 100644 --- a/zerver/views/__init__.py +++ b/zerver/views/__init__.py @@ -999,6 +999,7 @@ def home(request): avatar_url = avatar_url(user_profile), mandatory_topics = user_profile.realm.mandatory_topics, show_digest_email = user_profile.realm.show_digest_email, + presence_disabled = user_profile.realm.presence_disabled, ) if narrow_stream is not None: # In narrow_stream context, initial pointer is just latest message