events: Pass realm to fetch_initial_state_data always.

This commit makes passing realm mandatory to fetch_initial_state_data.

This is a prep commit for refetching the realm object with
select_related for group setting fields so that extra queries
can be avoided when computing "/registe" response.
This commit is contained in:
Sahil Batra
2024-06-15 10:42:06 +05:30
committed by Tim Abbott
parent 1455a68aef
commit dea62a3fd9
3 changed files with 26 additions and 19 deletions

View File

@@ -122,7 +122,7 @@ def always_want(msg_type: str) -> bool:
def fetch_initial_state_data(
user_profile: Optional[UserProfile],
*,
realm: Optional[Realm] = None,
realm: Realm,
event_types: Optional[Iterable[str]] = None,
queue_id: Optional[str] = "",
client_gravatar: bool = False,
@@ -148,10 +148,6 @@ def fetch_initial_state_data(
corresponding events for changes in the data structures and new
code to apply_events (and add a test in test_events.py).
"""
if realm is None:
assert user_profile is not None
realm = user_profile.realm
state: Dict[str, Any] = {"queue_id": queue_id}
if event_types is None:
@@ -1705,6 +1701,7 @@ def do_events_register(
ret = fetch_initial_state_data(
user_profile,
realm=realm,
event_types=event_types_set,
queue_id=queue_id,
client_gravatar=client_gravatar,