mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 00:46:03 +00:00
filter: Copy is_web_public_compatible from server to frontend.
This will be used to check if the narrow being requested by spectator requires authentication without requesting the server. Having this check locally, makes this process look snappy to the user and doesn't result in 404s in the browser log.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import Handlebars from "handlebars/runtime";
|
||||
import _ from "lodash";
|
||||
|
||||
import * as hash_util from "./hash_util";
|
||||
import {$t} from "./i18n";
|
||||
import * as message_edit from "./message_edit";
|
||||
import * as message_parser from "./message_parser";
|
||||
@@ -1005,4 +1006,16 @@ export class Filter {
|
||||
static describe(operators) {
|
||||
return Handlebars.Utils.escapeExpression(Filter.describe_unescaped(operators));
|
||||
}
|
||||
|
||||
static is_web_public_compatible(ops) {
|
||||
for (const op of ops) {
|
||||
if (op.operand === undefined) {
|
||||
return false;
|
||||
}
|
||||
if (!hash_util.allowed_web_public_narrows.includes(op.operator)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user