mirror of https://github.com/zulip/zulip.git
user_status: Fix parsing of partial user_status events.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
e0bd169c77
commit
43e53d9b9d
|
@ -10,34 +10,34 @@ export type UserStatusEmojiInfo = EmojiRenderingDetails & {
|
|||
emoji_alt_code?: boolean;
|
||||
};
|
||||
|
||||
const user_status_schema = z.intersection(
|
||||
z.object({
|
||||
status_text: z.string().optional(),
|
||||
away: z.boolean().optional(),
|
||||
}),
|
||||
z.union([
|
||||
z.object({
|
||||
emoji_name: z.string(),
|
||||
emoji_code: z.string(),
|
||||
reaction_type: z.string(),
|
||||
}),
|
||||
z.object({
|
||||
emoji_name: z.undefined(),
|
||||
}),
|
||||
]),
|
||||
);
|
||||
|
||||
const user_status_event_schema = z.intersection(
|
||||
z.object({
|
||||
id: z.number(),
|
||||
type: z.literal("user_status"),
|
||||
user_id: z.number(),
|
||||
}),
|
||||
user_status_schema,
|
||||
);
|
||||
|
||||
export type UserStatusEvent = z.infer<typeof user_status_event_schema>;
|
||||
|
||||
const user_status_event_schema = z.object({
|
||||
id: z.number(),
|
||||
type: z.literal("user_status"),
|
||||
user_id: z.number(),
|
||||
away: z.boolean().optional(),
|
||||
status_text: z.string(),
|
||||
emoji_name: z.string(),
|
||||
emoji_code: z.string(),
|
||||
reaction_type: z.string(),
|
||||
});
|
||||
|
||||
const user_status_schema = z.union([
|
||||
z.object({
|
||||
status_text: z.string().optional(),
|
||||
emoji_name: z.string(),
|
||||
emoji_code: z.string(),
|
||||
reaction_type: z.string(),
|
||||
away: z.boolean().optional(),
|
||||
}),
|
||||
z.object({
|
||||
emoji_name: z.undefined(),
|
||||
status_text: z.string().optional(),
|
||||
away: z.boolean().optional(),
|
||||
}),
|
||||
]);
|
||||
|
||||
const user_status_param_schema = z.record(z.string(), user_status_schema);
|
||||
|
||||
const user_info = new Map<number, string>();
|
||||
|
|
Loading…
Reference in New Issue