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.

narrow: Add helper to check allowed web public narrow.

opmkumarf7dea36abbe7
diff --git a/web/src/filter.ts b/web/src/filter.ts
index 6c09b595b3d..0377918f4bc 100644
--- a/web/src/filter.ts
+++ b/web/src/filter.ts
@@ -865,7 +865,7 @@ export class Filter {
if (term.operand === undefined) {
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;
}
}
diff --git a/web/src/hash_parser.ts b/web/src/hash_parser.ts
index 9e18ebe374b..b9011d1d2b1 100644
--- a/web/src/hash_parser.ts
+++ b/web/src/hash_parser.ts
@@ -116,6 +116,10 @@ export function is_in_specified_hash_category(hash_categories: string[]): boolea
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 = [
"channels",
"channel",
@@ -157,7 +161,7 @@ export function is_spectator_compatible(hash: string): boolean {
if (main_hash === "narrow") {
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 true;
diff --git a/web/src/message_view.ts b/web/src/message_view.ts
index cacf4092e20..bf3934bb736 100644
--- a/web/src/message_view.ts
+++ b/web/src/message_view.ts
@@ -444,8 +444,7 @@ export let show = (raw_terms: NarrowTerm[], show_opts: ShowMessageViewOpts): voi
// policy?
!is_combined_feed_global_view &&
raw_terms.some(
- (raw_term) =>
- !hash_parser.allowed_web_public_narrow_operators.includes(raw_term.operator),
+ (raw_term) => !hash_parser.is_an_allowed_web_public_narrow(raw_term.operator),
)
) {
spectators.login_to_access();