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.

zephyr/user_pill: Remove special condition for zephyr realm.

Aman Agrawalb1f6eb41d9b3
diff --git a/web/src/user_pill.ts b/web/src/user_pill.ts
index 57cd0faa244..d7b888f88f6 100644
--- a/web/src/user_pill.ts
+++ b/web/src/user_pill.ts
@@ -9,7 +9,6 @@ import type {InputPillConfig, InputPillContainer} from "./input_pill.ts";
import * as input_pill from "./input_pill.ts";
import type {User} from "./people.ts";
import * as people from "./people.ts";
-import {realm} from "./state_data.ts";
import type {
CombinedPill,
CombinedPillContainer,
@@ -22,7 +21,7 @@ import * as user_status from "./user_status.ts";
export type UserPill = {
type: "user";
- user_id?: number;
+ user_id: number;
email: string;
full_name: string | undefined;
img_src?: string;
@@ -41,25 +40,9 @@ export function create_item_from_email(
current_items: CombinedPill[],
pill_config?: InputPillConfig,
): UserPill | undefined {
- // For normal Zulip use, we need to validate the email for our realm.
const user = people.get_by_email(email);
if (!user) {
- if (realm.realm_is_zephyr_mirror_realm) {
- if (current_items.some((item) => item.type === "user" && item.email === email)) {
- return undefined;
- }
-
- // For Zephyr we can't assume any emails are invalid,
- // so we just create a pill where the display value
- // is the email itself.
- return {
- type: "user",
- full_name: undefined,
- email,
- };
- }
-
// The email is not allowed, so return.
return undefined;
}
@@ -136,7 +119,7 @@ export function get_user_ids(
pill_widget: UserPillWidget | CombinedPillContainer | GroupSettingPillContainer,
): number[] {
const items = pill_widget.items();
- return items.flatMap((item) => (item.type === "user" ? (item.user_id ?? []) : [])); // be defensive about undefined users
+ return items.flatMap((item) => (item.type === "user" ? item.user_id : []));
}
export function has_unconverted_data(pill_widget: UserPillWidget): boolean {
diff --git a/web/tests/user_pill.test.cjs b/web/tests/user_pill.test.cjs
index f2f4f5ab440..94d61bca7e8 100644
--- a/web/tests/user_pill.test.cjs
+++ b/web/tests/user_pill.test.cjs
@@ -78,17 +78,9 @@ test("create_item", ({override}) => {
assert.deepEqual(item, expected_item);
}
- override(realm, "realm_is_zephyr_mirror_realm", true);
settings_data.user_can_access_all_other_users = () => false;
- test_create_item("[email protected]", [], bogus_item);
test_create_item("[email protected]", [bogus_item], undefined);
-
- test_create_item("[email protected]", [], isaac_item);
- test_create_item("[email protected]", [isaac_item], undefined);
-
- override(realm, "realm_is_zephyr_mirror_realm", false);
-
test_create_item("[email protected]", [], undefined);
test_create_item("[email protected]", [], isaac_item);
test_create_item("[email protected]", [isaac_item], undefined);