starred_messages: Validate parameters with Zod.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2024-06-21 01:24:35 -07:00 committed by Tim Abbott
parent 9a94cb2269
commit ce71e5ad8c
2 changed files with 3 additions and 2 deletions

View File

@ -1,8 +1,9 @@
import * as message_store from "./message_store";
import type {StateData} from "./state_data";
export const starred_ids = new Set<number>();
export function initialize(starred_messages_params: {starred_messages: number[]}): void {
export function initialize(starred_messages_params: StateData["starred_messages"]): void {
starred_ids.clear();
for (const id of starred_messages_params.starred_messages) {

View File

@ -338,7 +338,7 @@ export const state_data_schema = z
)
.and(
z
.object({starred_messages: NOT_TYPED_YET})
.object({starred_messages: z.array(z.number())})
.transform((starred_messages) => ({starred_messages})),
)
.and(