mirror of https://github.com/zulip/zulip.git
register: Refactor to pass client_capabilities directly.
We extract values from client_capabilities directly in do_events_register where we decide how to process the extracted variables.
This commit is contained in:
parent
d97c891afe
commit
21ac1fb32c
|
@ -830,7 +830,7 @@ def do_events_register(user_profile: UserProfile, user_client: Client,
|
||||||
queue_lifespan_secs: int = 0,
|
queue_lifespan_secs: int = 0,
|
||||||
all_public_streams: bool = False,
|
all_public_streams: bool = False,
|
||||||
include_subscribers: bool = True,
|
include_subscribers: bool = True,
|
||||||
notification_settings_null: bool = False,
|
client_capabilities: Dict[str, bool] = {},
|
||||||
narrow: Iterable[Sequence[str]] = [],
|
narrow: Iterable[Sequence[str]] = [],
|
||||||
fetch_event_types: Optional[Iterable[str]] = None) -> Dict[str, Any]:
|
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
|
||||||
|
@ -838,6 +838,8 @@ def do_events_register(user_profile: UserProfile, user_client: Client,
|
||||||
# handling perspective to do it before contacting Tornado
|
# handling perspective to do it before contacting Tornado
|
||||||
check_supported_events_narrow_filter(narrow)
|
check_supported_events_narrow_filter(narrow)
|
||||||
|
|
||||||
|
notification_settings_null = client_capabilities.get('notification_settings_null', False)
|
||||||
|
|
||||||
if user_profile.realm.email_address_visibility != Realm.EMAIL_ADDRESS_VISIBILITY_EVERYONE:
|
if user_profile.realm.email_address_visibility != Realm.EMAIL_ADDRESS_VISIBILITY_EVERYONE:
|
||||||
# If real email addresses are not available to the user, their
|
# If real email addresses are not available to the user, their
|
||||||
# clients cannot compute gravatars, so we force-set it to false.
|
# clients cannot compute gravatars, so we force-set it to false.
|
||||||
|
|
|
@ -50,12 +50,11 @@ def events_register_backend(
|
||||||
|
|
||||||
if client_capabilities is None:
|
if client_capabilities is None:
|
||||||
client_capabilities = {}
|
client_capabilities = {}
|
||||||
notification_settings_null = client_capabilities.get("notification_settings_null", False)
|
|
||||||
|
|
||||||
ret = do_events_register(user_profile, request.client,
|
ret = do_events_register(user_profile, request.client,
|
||||||
apply_markdown, client_gravatar, slim_presence,
|
apply_markdown, client_gravatar, slim_presence,
|
||||||
event_types, queue_lifespan_secs, all_public_streams,
|
event_types, queue_lifespan_secs, all_public_streams,
|
||||||
narrow=narrow, include_subscribers=include_subscribers,
|
narrow=narrow, include_subscribers=include_subscribers,
|
||||||
notification_settings_null=notification_settings_null,
|
client_capabilities=client_capabilities,
|
||||||
fetch_event_types=fetch_event_types)
|
fetch_event_types=fetch_event_types)
|
||||||
return json_success(ret)
|
return json_success(ret)
|
||||||
|
|
|
@ -189,10 +189,14 @@ def home_real(request: HttpRequest) -> HttpResponse:
|
||||||
|
|
||||||
narrow, narrow_stream, narrow_topic = detect_narrowed_window(request, user_profile)
|
narrow, narrow_stream, narrow_topic = detect_narrowed_window(request, user_profile)
|
||||||
|
|
||||||
|
client_capabilities = {
|
||||||
|
'notification_settings_null': True,
|
||||||
|
}
|
||||||
|
|
||||||
register_ret = do_events_register(user_profile, request.client,
|
register_ret = do_events_register(user_profile, request.client,
|
||||||
apply_markdown=True, client_gravatar=True,
|
apply_markdown=True, client_gravatar=True,
|
||||||
slim_presence=True,
|
slim_presence=True,
|
||||||
notification_settings_null=True,
|
client_capabilities=client_capabilities,
|
||||||
narrow=narrow)
|
narrow=narrow)
|
||||||
update_last_reminder(user_profile)
|
update_last_reminder(user_profile)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue