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.

events: Send empty list for custom_profile_fields in spectator view.

Lauryn Menard171da34546ae
diff --git a/static/js/popovers.js b/static/js/popovers.js
index 623c079549f..079063ccf96 100644
--- a/static/js/popovers.js
+++ b/static/js/popovers.js
@@ -255,13 +255,13 @@ function render_user_info_popover(
const is_system_bot = user.is_system_bot;
const status_text = user_status.get_status_text(user.user_id);
const status_emoji_info = user_status.get_status_emoji(user.user_id);
+ const spectator_view = page_params.is_spectator;
// TODO: The show_manage_menu calculation can get a lot simpler
// if/when we allow muting bot users.
const can_manage_user = page_params.is_admin && !is_me && !is_system_bot;
- const show_manage_menu = muting_allowed || can_manage_user;
+ const show_manage_menu = !spectator_view && (muting_allowed || can_manage_user);
- const spectator_view = page_params.is_spectator;
let date_joined;
if (spectator_view) {
const dateFormat = new Intl.DateTimeFormat("default", {dateStyle: "long"});
diff --git a/zerver/lib/events.py b/zerver/lib/events.py
index 712f2678a87..74d5b29f810 100644
--- a/zerver/lib/events.py
+++ b/zerver/lib/events.py
@@ -146,11 +146,14 @@ def fetch_initial_state_data(
if want("alert_words"):
state["alert_words"] = [] if user_profile is None else user_alert_words(user_profile)
- # Spectators can't access full user profiles or personal settings,
- # so there's no need to send custom profile field data.
- if want("custom_profile_fields") and user_profile is not None:
- fields = custom_profile_fields_for_realm(realm.id)
- state["custom_profile_fields"] = [f.as_dict() for f in fields]
+ if want("custom_profile_fields"):
+ if user_profile is None:
+ # Spectators can't access full user profiles or
+ # personal settings, so we send an empty list.
+ state["custom_profile_fields"] = []
+ else:
+ fields = custom_profile_fields_for_realm(realm.id)
+ state["custom_profile_fields"] = [f.as_dict() for f in fields]
state["custom_profile_field_types"] = {
item[4]: {"id": item[0], "name": str(item[1])}
for item in CustomProfileField.ALL_FIELD_TYPES