mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 05:23:35 +00:00
presence: Rename get_status_dict().
We renamed this to get_presences_for_realm(), and we have the caller pass in realm, not user_profile.
This commit is contained in:
@@ -27,7 +27,10 @@ from zerver.lib.message import (
|
||||
remove_message_id_from_unread_mgs,
|
||||
)
|
||||
from zerver.lib.narrow import check_supported_events_narrow_filter, read_stop_words
|
||||
from zerver.lib.presence import get_status_dict, get_status_dict_by_user
|
||||
from zerver.lib.presence import (
|
||||
get_presences_for_realm,
|
||||
get_status_dict_by_user
|
||||
)
|
||||
from zerver.lib.push_notifications import push_notifications_enabled
|
||||
from zerver.lib.soft_deactivation import reactivate_user_if_soft_deactivated
|
||||
from zerver.lib.realm_icon import realm_icon_url
|
||||
@@ -122,7 +125,7 @@ def fetch_initial_state_data(user_profile: UserProfile,
|
||||
state['pointer'] = user_profile.pointer
|
||||
|
||||
if want('presence'):
|
||||
state['presences'] = get_status_dict(user_profile, slim_presence)
|
||||
state['presences'] = get_presences_for_realm(realm, slim_presence)
|
||||
|
||||
if want('realm'):
|
||||
for property_name in Realm.property_types:
|
||||
|
||||
@@ -11,6 +11,7 @@ from zerver.lib.timestamp import datetime_to_timestamp
|
||||
from zerver.models import (
|
||||
query_for_ids,
|
||||
PushDeviceToken,
|
||||
Realm,
|
||||
UserPresence,
|
||||
UserProfile,
|
||||
)
|
||||
@@ -148,17 +149,18 @@ def get_status_dict_by_realm(realm_id: int, slim_presence: bool = False) -> Dict
|
||||
|
||||
return get_status_dicts_for_rows(presence_rows, mobile_user_ids, slim_presence)
|
||||
|
||||
def get_status_dict(requesting_user_profile: UserProfile,
|
||||
slim_presence: bool) -> Dict[str, Dict[str, Dict[str, Any]]]:
|
||||
def get_presences_for_realm(realm: Realm,
|
||||
slim_presence: bool) -> Dict[str, Dict[str, Dict[str, Any]]]:
|
||||
|
||||
if requesting_user_profile.realm.presence_disabled:
|
||||
if realm.presence_disabled:
|
||||
# Return an empty dict if presence is disabled in this realm
|
||||
return defaultdict(dict)
|
||||
|
||||
return get_status_dict_by_realm(requesting_user_profile.realm_id, slim_presence)
|
||||
return get_status_dict_by_realm(realm.id, slim_presence)
|
||||
|
||||
def get_presence_response(requesting_user_profile: UserProfile,
|
||||
slim_presence: bool) -> Dict[str, Any]:
|
||||
realm = requesting_user_profile.realm
|
||||
server_timestamp = time.time()
|
||||
presences = get_status_dict(requesting_user_profile, slim_presence)
|
||||
presences = get_presences_for_realm(realm, slim_presence)
|
||||
return dict(presences=presences, server_timestamp=server_timestamp)
|
||||
|
||||
Reference in New Issue
Block a user