Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
users: Add "(guest)" to names for guest users.
Sahil Batra49a047c27fda
diff --git a/tools/lib/capitalization.py b/tools/lib/capitalization.pyindex 02c064b5e8b..1fd4a6077aa 100644--- a/tools/lib/capitalization.py+++ b/tools/lib/capitalization.py@@ -140,6 +140,10 @@ IGNORED_PHRASES = [r"does not apply to moderators and administrators",# Used in message-delete-time-limit setting labelr"does not apply to administrators",+ # Used as indicator with names for guest users.+ r"guest",+ # Used in pills for deactivated users.+ r"deactivated",]# Sort regexes in descending order of their lengths. As a result, thediff --git a/web/src/buddy_data.js b/web/src/buddy_data.jsindex 5759c14a5b2..6137578f1e8 100644--- a/web/src/buddy_data.js+++ b/web/src/buddy_data.js@@ -152,6 +152,7 @@ export function info_for(user_id) {user_circle_class,status_text,user_list_style,+ should_add_guest_user_indicator: people.should_add_guest_user_indicator(user_id),};}diff --git a/web/src/compose_validate.js b/web/src/compose_validate.jsindex 2550febdee2..43f7ef03151 100644--- a/web/src/compose_validate.js+++ b/web/src/compose_validate.js@@ -173,6 +173,7 @@ export function warn_if_mentioning_unsubscribed_user(mentioned, $textarea) {can_subscribe_other_users,name: mentioned.full_name,classname: compose_banner.CLASSNAMES.recipient_not_subscribed,+ should_add_guest_user_indicator: people.should_add_guest_user_indicator(user_id),};const new_row = render_not_subscribed_warning(context);diff --git a/web/src/input_pill.ts b/web/src/input_pill.tsindex 9fa5e296434..5184fc28212 100644--- a/web/src/input_pill.ts+++ b/web/src/input_pill.ts@@ -17,6 +17,7 @@ export type InputPillItem<T> = {img_src?: string;deactivated?: boolean;status_emoji_info?: EmojiRenderingDetails & {emoji_alt_code: boolean}; // TODO: Move this in user_status.js+ should_add_guest_user_indicator?: boolean;} & T;type InputPillCreateOptions<T> = {@@ -55,6 +56,7 @@ type InputPillRenderingDetails = {deactivated?: boolean;has_status?: boolean;status_emoji_info?: EmojiRenderingDetails & {emoji_alt_code: boolean};+ should_add_guest_user_indicator?: boolean;};// These are the functions that are exposed to other modules.@@ -156,6 +158,7 @@ export function create<T>(opts: InputPillCreateOptions<T>): InputPillContainer<Tdisplay_value: item.display_value,has_image,deactivated: item.deactivated,+ should_add_guest_user_indicator: item.should_add_guest_user_indicator,};if (has_image) {diff --git a/web/src/message_list_view.js b/web/src/message_list_view.jsindex 7b4efa369af..b33c50ac490 100644--- a/web/src/message_list_view.js+++ b/web/src/message_list_view.js@@ -418,6 +418,8 @@ export class MessageListView {message_container.sender_is_bot = people.sender_is_bot(message_container.msg);message_container.sender_is_guest = people.sender_is_guest(message_container.msg);+ message_container.should_add_guest_indicator_for_sender =+ people.should_add_guest_user_indicator(message_container.msg.sender_id);message_container.small_avatar_url = people.small_avatar_url(message_container.msg);if (message_container.msg.stream_id) {diff --git a/web/src/page_params.ts b/web/src/page_params.tsindex 70749a98e81..2042aed8e3b 100644--- a/web/src/page_params.ts+++ b/web/src/page_params.ts@@ -68,6 +68,7 @@ export const page_params: {realm_private_message_policy: number;realm_push_notifications_enabled: boolean;realm_sentry_key: string | undefined;+ realm_enable_guest_user_indicator: boolean;realm_upload_quota_mib: number | null;realm_uri: string;realm_user_group_edit_policy: number;diff --git a/web/src/people.ts b/web/src/people.tsindex 74c8b69576e..0fbc78bf48e 100644--- a/web/src/people.ts+++ b/web/src/people.ts@@ -770,6 +770,15 @@ export function user_is_bot(user_id: number): boolean {return user.is_bot;}+export function should_add_guest_user_indicator(user_id: number): boolean {+ if (!page_params.realm_enable_guest_user_indicator) {+ return false;+ }++ const user = get_by_user_id(user_id);+ return user.is_guest;+}+export function user_can_direct_message(recipient_ids_string: string): boolean {// Common function for checking if a user can send a direct// message to the target user (or group of users) represented by adiff --git a/web/src/search_suggestion.js b/web/src/search_suggestion.jsindex 0abd25635e4..a83c7acf532 100644--- a/web/src/search_suggestion.js+++ b/web/src/search_suggestion.js@@ -34,6 +34,7 @@ function highlight_person(person, highlighter) {display_value: new Handlebars.SafeString(highlighted_name),has_image: true,img_src: avatar_url,+ should_add_guest_user_indicator: people.should_add_guest_user_indicator(person.user_id),};}diff --git a/web/src/typeahead_helper.js b/web/src/typeahead_helper.jsindex 065163d2238..cdc9b6da277 100644--- a/web/src/typeahead_helper.js+++ b/web/src/typeahead_helper.js@@ -92,6 +92,7 @@ export function render_person(person) {user_circle_class,is_person: true,status_emoji_info,+ should_add_guest_user_indicator: people.should_add_guest_user_indicator(person.user_id),};typeahead_arguments.secondary = person.delivery_email;diff --git a/web/src/user_card_popover.js b/web/src/user_card_popover.jsindex f09f4337872..9dbca15c53b 100644--- a/web/src/user_card_popover.js+++ b/web/src/user_card_popover.js@@ -289,6 +289,7 @@ function get_user_card_popover_data(user_mention_syntax: people.get_mention_syntax(user.full_name, user.user_id),date_joined,spectator_view,+ should_add_guest_user_indicator: people.should_add_guest_user_indicator(user.user_id),};if (user.is_bot) {diff --git a/web/src/user_pill.js b/web/src/user_pill.jsindex a4ea3977bcd..9bf608f86af 100644--- a/web/src/user_pill.js+++ b/web/src/user_pill.js@@ -53,12 +53,12 @@ export function create_item_from_email(email, current_items) {img_src: avatar_url,deactivated: false,status_emoji_info,+ should_add_guest_user_indicator: people.should_add_guest_user_indicator(user.user_id),};// We pass deactivated true for a deactivated userif (!people.is_person_active(user.user_id)) {item.deactivated = true;- item.display_value = user.full_name + " (deactivated)";}return item;@@ -81,6 +81,7 @@ export function append_person(opts) {email: person.email,img_src: avatar_url,status_emoji_info,+ should_add_guest_user_indicator: people.should_add_guest_user_indicator(person.user_id),};pill_widget.appendValidatedData(pill_data);diff --git a/web/src/user_profile.js b/web/src/user_profile.jsindex 96d77e53afd..181b64bd047 100644--- a/web/src/user_profile.js+++ b/web/src/user_profile.js@@ -366,6 +366,7 @@ export function show_user_profile(user, default_tab_key = "profile-tab") {user_is_guest: user.is_guest,show_user_subscribe_widget,can_manage_profile,+ should_add_guest_user_indicator: people.should_add_guest_user_indicator(user.user_id),};if (user.is_bot) {diff --git a/web/styles/popovers.css b/web/styles/popovers.cssindex e3b043f802d..2342dca6d00 100644--- a/web/styles/popovers.css+++ b/web/styles/popovers.css@@ -223,7 +223,7 @@ ul {display: inline-block;text-align: center;- &:not(.popover_action_icon) {+ &:not(.popover_action_icon, .guest-indicator) {width: 14px;}diff --git a/web/templates/compose_banner/not_subscribed_warning.hbs b/web/templates/compose_banner/not_subscribed_warning.hbsindex a809195bd1d..7a11fc0323d 100644--- a/web/templates/compose_banner/not_subscribed_warning.hbs+++ b/web/templates/compose_banner/not_subscribed_warning.hbs@@ -1,9 +1,17 @@{{#> compose_banner }}<p class="banner_message">{{#if can_subscribe_other_users}}+ {{#if should_add_guest_user_indicator}}+ {{#tr}}<strong>{name}</strong> <i>(guest)</i> is not subscribed to this stream. They will not be notified unless you subscribe them.{{/tr}}+ {{else}}{{#tr}}<strong>{name}</strong> is not subscribed to this stream. They will not be notified unless you subscribe them.{{/tr}}+ {{/if}}{{else}}+ {{#if should_add_guest_user_indicator}}+ {{#tr}}<strong>{name}</strong> <i>(guest)</i> is not subscribed to this stream. They will not be notified if you mention them.{{/tr}}+ {{else}}{{#tr}}<strong>{name}</strong> is not subscribed to this stream. They will not be notified if you mention them.{{/tr}}+ {{/if}}{{/if}}</p>{{/compose_banner}}diff --git a/web/templates/input_pill.hbs b/web/templates/input_pill.hbsindex 53bc1520c4f..2dfb00256db 100644--- a/web/templates/input_pill.hbs+++ b/web/templates/input_pill.hbs@@ -4,6 +4,8 @@{{/if}}<span class="pill-label"><span class="pill-value">{{ display_value }}</span>+ {{~#if should_add_guest_user_indicator}} <i>({{t 'guest'}})</i>{{~/if~}}+ {{~#if deactivated}} ({{t 'deactivated'}}){{~/if~}}{{~#if has_status~}}{{~> status_emoji status_emoji_info~}}{{~/if~}}diff --git a/web/templates/message_body.hbs b/web/templates/message_body.hbsindex f1ecfe2eaa7..14f520f5ad6 100644--- a/web/templates/message_body.hbs+++ b/web/templates/message_body.hbs@@ -5,7 +5,7 @@{{#if include_sender}}<span class="sender_info_hover sender_name" role="button" tabindex="0"><span class="view_user_card_tooltip sender_name_text" data-tooltip-template-id="view-user-card-tooltip-template">- {{msg/sender_full_name}}+ {{> user_full_name name=msg/sender_full_name should_add_guest_user_indicator=should_add_guest_indicator_for_sender}}</span>{{#unless status_message}}{{> status_emoji msg/status_emoji_info}}diff --git a/web/templates/popovers/user_card/user_card_popover.hbs b/web/templates/popovers/user_card/user_card_popover.hbsindex 954504cf568..fdeeafd8332 100644--- a/web/templates/popovers/user_card/user_card_popover.hbs+++ b/web/templates/popovers/user_card/user_card_popover.hbs@@ -3,7 +3,7 @@<div class="user-card-popover-content no-auto-hide-right-sidebar-overlay"><ul class="nav nav-list user-card-popover-actions" id="user_card_popover" data-user-id="{{user_id}}"><li class="popover_user_name_row">- <b class="user_full_name" data-tippy-content="{{user_full_name}}">{{user_full_name}}</b>+ <b class="user_full_name" data-tippy-content="{{user_full_name}}">{{> ../../user_full_name name=user_full_name}}</b>{{#if is_active }}{{#if is_bot}}<i class="zulip-icon zulip-icon-bot" aria-hidden="true"></i>diff --git a/web/templates/presence_row.hbs b/web/templates/presence_row.hbsindex 690e321df73..a8ca9e2ff7d 100644--- a/web/templates/presence_row.hbs+++ b/web/templates/presence_row.hbs@@ -8,13 +8,13 @@{{#if user_list_style.WITH_STATUS}}<div class="user-name-and-status-wrapper"><div class="user-name-and-status-emoji">- <span class="user-name">{{name}}</span>+ <span class="user-name">{{> user_full_name}}</span>{{> status_emoji status_emoji_info}}</div><span class="status-text">{{status_text}}</span></div>{{else}}- <span class="user-name">{{name}}</span>+ {{> user_full_name}}{{> status_emoji status_emoji_info}}{{/if}}</a>diff --git a/web/templates/typeahead_list_item.hbs b/web/templates/typeahead_list_item.hbsindex 49fb2f21c22..e4a7f542c82 100644--- a/web/templates/typeahead_list_item.hbs+++ b/web/templates/typeahead_list_item.hbs@@ -24,6 +24,9 @@{{~ primary ~}}{{/if}}</strong>+{{~#if should_add_guest_user_indicator}}+ <i>({{t 'guest'}})</i>+{{~/if}}{{~#if has_status}}{{> status_emoji status_emoji_info}}{{~/if}}diff --git a/web/templates/user_full_name.hbs b/web/templates/user_full_name.hbsnew file mode 100644index 00000000000..8103610f43d--- /dev/null+++ b/web/templates/user_full_name.hbs@@ -0,0 +1,5 @@+{{#if should_add_guest_user_indicator}}+{{#tr}}{name} <i class="guest-indicator">(guest)</i>{{/tr}}+{{else}}+<span class="user-name">{{name}}</span>+{{/if}}diff --git a/web/templates/user_profile_modal.hbs b/web/templates/user_profile_modal.hbsindex 4677d864198..dafc8a50d83 100644--- a/web/templates/user_profile_modal.hbs+++ b/web/templates/user_profile_modal.hbs@@ -11,7 +11,7 @@{{#if is_bot}}<i class="zulip-icon zulip-icon-bot" aria-hidden="true"></i>{{/if}}- <span class="user_profile_name">{{full_name}}</span>+ <span class="user_profile_name">{{> user_full_name name=full_name}}</span>{{#if is_me}}<a href="/#settings/profile"><i class="fa fa-edit tippy-zulip-tooltip user_profile_manage_own_edit_button" data-tippy-content="{{t 'Edit profile' }}" aria-hidden="true"></i>diff --git a/web/tests/activity.test.js b/web/tests/activity.test.jsindex 4ed8fab2501..6577c267ef1 100644--- a/web/tests/activity.test.js+++ b/web/tests/activity.test.js@@ -400,6 +400,7 @@ test("first/prev/next", ({override, mock_template}) => {WITH_STATUS: true,WITH_AVATAR: false,},+ should_add_guest_user_indicator: false,});break;case fred.user_id:@@ -419,6 +420,7 @@ test("first/prev/next", ({override, mock_template}) => {WITH_STATUS: true,WITH_AVATAR: false,},+ should_add_guest_user_indicator: false,});break;/* istanbul ignore next */@@ -489,6 +491,7 @@ test("insert_one_user_into_empty_list", ({override, mock_template}) => {WITH_STATUS: true,WITH_AVATAR: false,},+ should_add_guest_user_indicator: false,});assert.ok(html.startsWith("<li data-user-id="));return html;diff --git a/web/tests/buddy_data.test.js b/web/tests/buddy_data.test.jsindex e11522d6dc4..db754bac034 100644--- a/web/tests/buddy_data.test.js+++ b/web/tests/buddy_data.test.js@@ -519,6 +519,7 @@ test("get_items_for_users", () => {user_circle_class: "user_circle_green",user_id: 1001,user_list_style,+ should_add_guest_user_indicator: false,},{faded: false,@@ -531,6 +532,7 @@ test("get_items_for_users", () => {user_circle_class: "user_circle_empty",user_id: 1002,user_list_style,+ should_add_guest_user_indicator: false,},{faded: false,@@ -543,6 +545,7 @@ test("get_items_for_users", () => {user_circle_class: "user_circle_empty",user_id: 1003,user_list_style,+ should_add_guest_user_indicator: false,},]);});diff --git a/web/tests/compose_pm_pill.test.js b/web/tests/compose_pm_pill.test.jsindex 802af767c29..1522faa3679 100644--- a/web/tests/compose_pm_pill.test.js+++ b/web/tests/compose_pm_pill.test.js@@ -124,7 +124,7 @@ run_test("pills", ({override, override_rewire}) => {assert.ok(get_by_email_called);assert.equal(typeof res, "object");assert.equal(res.user_id, iago.user_id);- assert.equal(res.display_value, iago.full_name + " (deactivated)");+ assert.equal(res.display_value, iago.full_name);assert.ok(res.deactivated);people.add_active_user(iago);})();diff --git a/web/tests/message_list_view.test.js b/web/tests/message_list_view.test.jsindex 5836f42ff00..9db8bd3a174 100644--- a/web/tests/message_list_view.test.js+++ b/web/tests/message_list_view.test.js@@ -37,6 +37,7 @@ mock_esm("../src/rows", {mock_esm("../src/people", {sender_is_bot: () => false,sender_is_guest: () => false,+ should_add_guest_user_indicator: () => false,small_avatar_url: () => "fake/small/avatar/url",});diff --git a/web/tests/people.test.js b/web/tests/people.test.jsindex 525de113d77..f3242bdb04f 100644--- a/web/tests/people.test.js+++ b/web/tests/people.test.js@@ -1276,6 +1276,19 @@ test_people("get_realm_active_human_users", () => {assert.deepEqual(humans, [me]);});+test_people("should_show_guest_user_indicator", () => {+ people.add_active_user(charles);+ people.add_active_user(guest);++ page_params.realm_enable_guest_user_indicator = false;+ assert.equal(people.should_add_guest_user_indicator(charles.user_id), false);+ assert.equal(people.should_add_guest_user_indicator(guest.user_id), false);++ page_params.realm_enable_guest_user_indicator = true;+ assert.equal(people.should_add_guest_user_indicator(charles.user_id), false);+ assert.equal(people.should_add_guest_user_indicator(guest.user_id), true);+});+// reset to native Date()run_test("reset MockDate", () => {MockDate.reset();diff --git a/web/tests/search_suggestion.test.js b/web/tests/search_suggestion.test.jsindex 44d28c5b2ab..f91b6798464 100644--- a/web/tests/search_suggestion.test.js+++ b/web/tests/search_suggestion.test.js@@ -853,6 +853,7 @@ test("people_suggestions", ({override, mock_template}) => {user_id: 202,full_name: "Bob Térry",avatar_url: example_avatar_url,+ is_guest: false,};const alice = {@@ -917,6 +918,31 @@ test("people_suggestions", ({override, mock_template}) => {assert.equal(get_avatar_url("sender:[email protected]"), expectedString);assert.equal(get_avatar_url("dm-including:[email protected]"), expectedString);+ function get_should_add_guest_user_indicator(q) {+ return suggestions.lookup_table.get(q).user_pill_context.should_add_guest_user_indicator;+ }++ page_params.realm_enable_guest_user_indicator = true;+ suggestions = get_suggestions(query);++ assert.equal(get_should_add_guest_user_indicator("dm:[email protected]"), false);+ assert.equal(get_should_add_guest_user_indicator("sender:[email protected]"), false);+ assert.equal(get_should_add_guest_user_indicator("dm-including:[email protected]"), false);++ bob.is_guest = true;+ suggestions = get_suggestions(query);++ assert.equal(get_should_add_guest_user_indicator("dm:[email protected]"), true);+ assert.equal(get_should_add_guest_user_indicator("sender:[email protected]"), true);+ assert.equal(get_should_add_guest_user_indicator("dm-including:[email protected]"), true);++ page_params.realm_enable_guest_user_indicator = false;+ suggestions = get_suggestions(query);++ assert.equal(get_should_add_guest_user_indicator("dm:[email protected]"), false);+ assert.equal(get_should_add_guest_user_indicator("sender:[email protected]"), false);+ assert.equal(get_should_add_guest_user_indicator("dm-including:[email protected]"), false);+suggestions = get_suggestions("Ted "); // note spaceexpected = ["Ted", "sender:[email protected]", "dm:[email protected]", "dm-including:[email protected]"];diff --git a/web/tests/settings_user_groups_legacy.test.js b/web/tests/settings_user_groups_legacy.test.jsindex 8174e6d7b6d..dedcce4bfdc 100644--- a/web/tests/settings_user_groups_legacy.test.js+++ b/web/tests/settings_user_groups_legacy.test.js@@ -306,7 +306,7 @@ test_ui("populate_user_groups", ({mock_template, override, override_rewire}) =>assert.ok(get_by_email_called);assert.equal(typeof res, "object");assert.equal(res.user_id, bob.user_id);- assert.equal(res.display_value, bob.full_name + " (deactivated)");+ assert.equal(res.display_value, bob.full_name);assert.ok(res.deactivated);people.add_active_user(bob);})();diff --git a/web/tests/user_pill.test.js b/web/tests/user_pill.test.jsindex f0dfb9dc808..8d6565172ea 100644--- a/web/tests/user_pill.test.js+++ b/web/tests/user_pill.test.js@@ -36,6 +36,7 @@ const isaac_item = {deactivated: false,img_src: `http://zulip.zulipdev.com/avatar/${isaac.user_id}?s=50`,status_emoji_info: undefined,+ should_add_guest_user_indicator: false,};let pill_widget = {};