minor: Format some code in events.py.

This commit is contained in:
Steve Howell
2020-10-14 12:25:45 +00:00
committed by Tim Abbott
parent 193ca397f9
commit 79803f01f4

View File

@@ -81,13 +81,16 @@ def always_want(msg_type: str) -> bool:
''' '''
return True return True
def fetch_initial_state_data(user_profile: Optional[UserProfile], def fetch_initial_state_data(
event_types: Optional[Iterable[str]], user_profile: Optional[UserProfile],
queue_id: Optional[str], client_gravatar: bool, event_types: Optional[Iterable[str]],
user_avatar_url_field_optional: bool, queue_id: Optional[str],
realm: Realm, client_gravatar: bool,
slim_presence: bool = False, user_avatar_url_field_optional: bool,
include_subscribers: bool = True) -> Dict[str, Any]: realm: Realm,
slim_presence: bool = False,
include_subscribers: bool = True
) -> Dict[str, Any]:
"""When `event_types` is None, fetches the core data powering the """When `event_types` is None, fetches the core data powering the
webapp's `page_params` and `/api/v1/register` (for mobile/terminal webapp's `page_params` and `/api/v1/register` (for mobile/terminal
apps). Can also fetch a subset as determined by `event_types`. apps). Can also fetch a subset as determined by `event_types`.
@@ -901,17 +904,20 @@ def apply_event(state: Dict[str, Any],
else: else:
raise AssertionError("Unexpected event type {}".format(event['type'])) raise AssertionError("Unexpected event type {}".format(event['type']))
def do_events_register(user_profile: UserProfile, user_client: Client, def do_events_register(
apply_markdown: bool = True, user_profile: UserProfile,
client_gravatar: bool = False, user_client: Client,
slim_presence: bool = False, apply_markdown: bool = True,
event_types: Optional[Iterable[str]] = None, client_gravatar: bool = False,
queue_lifespan_secs: int = 0, slim_presence: bool = False,
all_public_streams: bool = False, event_types: Optional[Iterable[str]] = None,
include_subscribers: bool = True, queue_lifespan_secs: int = 0,
client_capabilities: Dict[str, bool] = {}, all_public_streams: bool = False,
narrow: Iterable[Sequence[str]] = [], include_subscribers: bool = True,
fetch_event_types: Optional[Iterable[str]] = None) -> Dict[str, Any]: client_capabilities: Dict[str, bool] = {},
narrow: Iterable[Sequence[str]] = [],
fetch_event_types: Optional[Iterable[str]] = None
) -> Dict[str, Any]:
# Technically we don't need to check this here because # Technically we don't need to check this here because
# build_narrow_filter will check it, but it's nicer from an error # build_narrow_filter will check it, but it's nicer from an error
# handling perspective to do it before contacting Tornado # handling perspective to do it before contacting Tornado
@@ -947,12 +953,16 @@ def do_events_register(user_profile: UserProfile, user_client: Client,
# Fill up the UserMessage rows if a soft-deactivated user has returned # Fill up the UserMessage rows if a soft-deactivated user has returned
reactivate_user_if_soft_deactivated(user_profile) reactivate_user_if_soft_deactivated(user_profile)
ret = fetch_initial_state_data(user_profile, event_types_set, queue_id, ret = fetch_initial_state_data(
client_gravatar=client_gravatar, user_profile,
user_avatar_url_field_optional=user_avatar_url_field_optional, event_types_set,
realm=user_profile.realm, queue_id,
slim_presence=slim_presence, client_gravatar=client_gravatar,
include_subscribers=include_subscribers) user_avatar_url_field_optional=user_avatar_url_field_optional,
realm=user_profile.realm,
slim_presence=slim_presence,
include_subscribers=include_subscribers
)
# Apply events that came in while we were fetching initial data # Apply events that came in while we were fetching initial data
events = get_user_events(user_profile, queue_id, -1) events = get_user_events(user_profile, queue_id, -1)