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>
(cherry picked from commit dd3a8ce3b5
)
This commit is contained in:
parent
87d6ef4df7
commit
bb7b9af676
|
@ -10,33 +10,33 @@ export type UserStatusEmojiInfo = EmojiRenderingDetails & {
|
|||
emoji_alt_code?: boolean;
|
||||
};
|
||||
|
||||
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([
|
||||
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(),
|
||||
away: z.boolean().optional(),
|
||||
}),
|
||||
z.object({
|
||||
emoji_name: z.undefined(),
|
||||
status_text: z.string().optional(),
|
||||
away: z.boolean().optional(),
|
||||
}),
|
||||
]);
|
||||
]),
|
||||
);
|
||||
|
||||
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_param_schema = z.record(z.string(), user_status_schema);
|
||||
|
||||
|
|
Loading…
Reference in New Issue