Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

minor: Clean up args for apply_events.

Steve Howelle42baf9e1307
diff --git a/zerver/lib/events.py b/zerver/lib/events.py
index acb11480a24..d894b66ba0b 100644
--- a/zerver/lib/events.py
+++ b/zerver/lib/events.py
@@ -417,10 +417,16 @@ def fetch_initial_state_data(
return state
-def apply_events(state: Dict[str, Any], events: Iterable[Dict[str, Any]],
- user_profile: UserProfile, client_gravatar: bool,
- slim_presence: bool, include_subscribers: bool = True,
- fetch_event_types: Optional[Iterable[str]] = None) -> None:
+def apply_events(
+ user_profile: UserProfile,
+ *,
+ state: Dict[str, Any],
+ events: Iterable[Dict[str, Any]],
+ fetch_event_types: Optional[Iterable[str]],
+ client_gravatar: bool,
+ slim_presence: bool,
+ include_subscribers: bool,
+) -> None:
for event in events:
if fetch_event_types is not None and event['type'] not in fetch_event_types:
# TODO: continuing here is not, most precisely, correct.
@@ -987,9 +993,15 @@ def do_events_register(
# Apply events that came in while we were fetching initial data
events = get_user_events(user_profile, queue_id, -1)
- apply_events(ret, events, user_profile, include_subscribers=include_subscribers,
- client_gravatar=client_gravatar, slim_presence=slim_presence,
- fetch_event_types=fetch_event_types)
+ apply_events(
+ user_profile,
+ state=ret,
+ events=events,
+ fetch_event_types=fetch_event_types,
+ client_gravatar=client_gravatar,
+ slim_presence=slim_presence,
+ include_subscribers=include_subscribers,
+ )
post_process_state(user_profile, ret, notification_settings_null)
diff --git a/zerver/tests/test_events.py b/zerver/tests/test_events.py
index 20bc0f3af99..878e7aa6972 100644
--- a/zerver/tests/test_events.py
+++ b/zerver/tests/test_events.py
@@ -261,10 +261,15 @@ class BaseAction(ZulipTestCase):
initial_state = copy.deepcopy(hybrid_state)
post_process_state(self.user_profile, initial_state, notification_settings_null)
before = orjson.dumps(initial_state)
- apply_events(hybrid_state, events, self.user_profile,
- client_gravatar=client_gravatar,
- slim_presence=slim_presence,
- include_subscribers=include_subscribers)
+ apply_events(
+ self.user_profile,
+ state=hybrid_state,
+ events=events,
+ fetch_event_types=None,
+ client_gravatar=client_gravatar,
+ slim_presence=slim_presence,
+ include_subscribers=include_subscribers,
+ )
post_process_state(self.user_profile, hybrid_state, notification_settings_null)
after = orjson.dumps(hybrid_state)