mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 15:03:34 +00:00
composebox_typeahead: Hide user groups from mention typeahead.
This commit adds code to hide the user groups which a user is not allowed to mention from the mention typeahead. Fixes a part of #25927.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import * as blueslip from "./blueslip";
|
||||
import {FoldDict} from "./fold_dict";
|
||||
import * as group_permission_settings from "./group_permission_settings";
|
||||
import {page_params} from "./page_params";
|
||||
import * as settings_config from "./settings_config";
|
||||
import type {User, UserGroupUpdateEvent} from "./types";
|
||||
|
||||
@@ -88,6 +89,21 @@ export function get_realm_user_groups(): UserGroup[] {
|
||||
return user_groups.filter((group) => !group.is_system_group);
|
||||
}
|
||||
|
||||
export function get_user_groups_allowed_to_mention(): UserGroup[] {
|
||||
if (page_params.user_id === undefined) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const user_groups = get_realm_user_groups();
|
||||
return user_groups.filter((group) => {
|
||||
const can_mention_group_id = group.can_mention_group_id;
|
||||
return (
|
||||
page_params.user_id !== undefined &&
|
||||
is_user_in_group(can_mention_group_id, page_params.user_id)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
export function is_direct_member_of(user_id: number, user_group_id: number): boolean {
|
||||
const user_group = user_group_by_id_dict.get(user_group_id);
|
||||
if (user_group === undefined) {
|
||||
|
||||
Reference in New Issue
Block a user