mirror of
https://github.com/zulip/zulip.git
synced 2026-06-30 21:11:04 +08:00
linkifiers: Extract realm_linkifier_schema.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
defe5e0128
commit
8d52e09f18
@ -1,6 +1,8 @@
|
||||
import * as url_template_lib from "url-template";
|
||||
import type {z} from "zod";
|
||||
|
||||
import * as blueslip from "./blueslip.ts";
|
||||
import type {realm_linkifier_schema} from "./state_data.ts";
|
||||
|
||||
type LinkifierMap = Map<
|
||||
RegExp,
|
||||
@ -8,11 +10,7 @@ type LinkifierMap = Map<
|
||||
>;
|
||||
const linkifier_map: LinkifierMap = new Map();
|
||||
|
||||
type Linkifier = {
|
||||
pattern: string;
|
||||
url_template: string;
|
||||
id: number;
|
||||
};
|
||||
type Linkifier = z.output<typeof realm_linkifier_schema>;
|
||||
|
||||
export function get_linkifier_map(): LinkifierMap {
|
||||
return linkifier_map;
|
||||
|
||||
@ -238,6 +238,12 @@ const custom_profile_field_types_schema = z.object({
|
||||
|
||||
export type CustomProfileFieldTypes = z.infer<typeof custom_profile_field_types_schema>;
|
||||
|
||||
export const realm_linkifier_schema = z.object({
|
||||
pattern: z.string(),
|
||||
url_template: z.string(),
|
||||
id: z.number(),
|
||||
});
|
||||
|
||||
// Sync this with zerver.lib.events.do_events_register.
|
||||
export const realm_schema = z.object({
|
||||
custom_profile_fields: z.array(custom_profile_field_schema),
|
||||
@ -349,13 +355,7 @@ export const realm_schema = z.object({
|
||||
realm_invite_to_stream_policy: z.number(),
|
||||
realm_is_zephyr_mirror_realm: z.boolean(),
|
||||
realm_jitsi_server_url: z.nullable(z.string()),
|
||||
realm_linkifiers: z.array(
|
||||
z.object({
|
||||
pattern: z.string(),
|
||||
url_template: z.string(),
|
||||
id: z.number(),
|
||||
}),
|
||||
),
|
||||
realm_linkifiers: z.array(realm_linkifier_schema),
|
||||
realm_logo_source: z.string(),
|
||||
realm_logo_url: z.string(),
|
||||
realm_mandatory_topics: z.boolean(),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user