mirror of
https://github.com/zulip/zulip.git
synced 2026-06-24 21:08:25 +08:00
zerver/lib/events: Refactor fetch_initial_state_data.
This Refactors the function fetch_initial_state_data to use the realm.property_types attribute, avoiding some unnecessary code duplication. Tweaked slightly by tabbott to simplify the code a bit. Addresses part of issue #3854.
This commit is contained in:
parent
6ff78ca0e8
commit
95ff65b290
@ -29,7 +29,7 @@ from zerver.lib.actions import validate_user_access_to_subscribers_helper, \
|
||||
gather_subscriptions_helper, get_realm_domains, \
|
||||
get_status_dict, streams_to_dicts_sorted
|
||||
from zerver.tornado.event_queue import request_event_queue, get_user_events
|
||||
from zerver.models import Client, Message, UserProfile, \
|
||||
from zerver.models import Client, Message, Realm, UserProfile, \
|
||||
get_user_profile_by_email, get_user_profile_by_id, \
|
||||
get_active_user_dicts_in_realm, realm_filters_for_realm, \
|
||||
get_owned_bot_dicts, custom_profile_fields_for_realm
|
||||
@ -101,25 +101,13 @@ def fetch_initial_state_data(user_profile, event_types, queue_id,
|
||||
state['presences'] = get_status_dict(user_profile)
|
||||
|
||||
if want('realm'):
|
||||
state['realm_name'] = user_profile.realm.name
|
||||
state['realm_description'] = user_profile.realm.description
|
||||
state['realm_restricted_to_domain'] = user_profile.realm.restricted_to_domain
|
||||
state['realm_invite_required'] = user_profile.realm.invite_required
|
||||
state['realm_invite_by_admins_only'] = user_profile.realm.invite_by_admins_only
|
||||
state['realm_inline_image_preview'] = user_profile.realm.inline_image_preview
|
||||
state['realm_inline_url_embed_preview'] = user_profile.realm.inline_url_embed_preview
|
||||
for property_name in Realm.property_types:
|
||||
state['realm_' + property_name] = getattr(user_profile.realm, property_name)
|
||||
state['realm_authentication_methods'] = user_profile.realm.authentication_methods_dict()
|
||||
state['realm_create_stream_by_admins_only'] = user_profile.realm.create_stream_by_admins_only
|
||||
state['realm_add_emoji_by_admins_only'] = user_profile.realm.add_emoji_by_admins_only
|
||||
state['realm_allow_message_editing'] = user_profile.realm.allow_message_editing
|
||||
state['realm_message_content_edit_limit_seconds'] = user_profile.realm.message_content_edit_limit_seconds
|
||||
state['realm_message_retention_days'] = user_profile.realm.message_retention_days
|
||||
state['realm_default_language'] = user_profile.realm.default_language
|
||||
state['realm_waiting_period_threshold'] = user_profile.realm.waiting_period_threshold
|
||||
state['realm_icon_url'] = realm_icon_url(user_profile.realm)
|
||||
state['realm_icon_source'] = user_profile.realm.icon_source
|
||||
state['realm_name_changes_disabled'] = user_profile.realm.name_changes_disabled
|
||||
state['realm_email_changes_disabled'] = user_profile.realm.email_changes_disabled
|
||||
state['max_icon_file_size'] = settings.MAX_ICON_FILE_SIZE
|
||||
state['realm_bot_domain'] = user_profile.realm.get_bot_domain()
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user