mirror of
https://github.com/zulip/zulip.git
synced 2025-11-14 10:57:58 +00:00
narrow: Add helper to check allowed web public narrow.
Adds a helper function to check whether a narrow is an allowed web public narrow or not.
This commit is contained in:
@@ -865,7 +865,7 @@ export class Filter {
|
|||||||
if (term.operand === undefined) {
|
if (term.operand === undefined) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!hash_parser.allowed_web_public_narrow_operators.includes(term.operator)) {
|
if (!hash_parser.is_an_allowed_web_public_narrow(term.operator)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,6 +116,10 @@ export function is_in_specified_hash_category(hash_categories: string[]): boolea
|
|||||||
return hash_categories.includes(main_hash);
|
return hash_categories.includes(main_hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function is_an_allowed_web_public_narrow(operator: string): boolean {
|
||||||
|
return allowed_web_public_narrow_operators.includes(operator);
|
||||||
|
}
|
||||||
|
|
||||||
export const allowed_web_public_narrow_operators = [
|
export const allowed_web_public_narrow_operators = [
|
||||||
"channels",
|
"channels",
|
||||||
"channel",
|
"channel",
|
||||||
@@ -157,7 +161,7 @@ export function is_spectator_compatible(hash: string): boolean {
|
|||||||
|
|
||||||
if (main_hash === "narrow") {
|
if (main_hash === "narrow") {
|
||||||
const hash_section = get_hash_section(hash);
|
const hash_section = get_hash_section(hash);
|
||||||
if (!allowed_web_public_narrow_operators.includes(hash_section)) {
|
if (!is_an_allowed_web_public_narrow(hash_section)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -444,8 +444,7 @@ export let show = (raw_terms: NarrowTerm[], show_opts: ShowMessageViewOpts): voi
|
|||||||
// policy?
|
// policy?
|
||||||
!is_combined_feed_global_view &&
|
!is_combined_feed_global_view &&
|
||||||
raw_terms.some(
|
raw_terms.some(
|
||||||
(raw_term) =>
|
(raw_term) => !hash_parser.is_an_allowed_web_public_narrow(raw_term.operator),
|
||||||
!hash_parser.allowed_web_public_narrow_operators.includes(raw_term.operator),
|
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
spectators.login_to_access();
|
spectators.login_to_access();
|
||||||
|
|||||||
Reference in New Issue
Block a user