fix: update channel message schema

This commit is contained in:
himself65
2023-03-30 18:33:09 -05:00
parent bb1224f9ee
commit f935bbaf5d
2 changed files with 4 additions and 2 deletions

View File

@@ -99,7 +99,7 @@ export const userSchema = z.object({
name: z.string(),
email: z.string(),
avatar_url: z.string(),
create_at: z.string(),
created_at: z.number(),
});
export const workspaceSchema = z.object({
@@ -113,6 +113,7 @@ export type Workspace = z.infer<typeof workspaceSchema>;
export const workspaceDetailSchema = z.object({
...workspaceSchema.shape,
permission: z.undefined(),
owner: userSchema,
member_count: z.number(),
});

View File

@@ -14,7 +14,7 @@ const channelMessageSchema = z.object({
ws_details: z.record(workspaceDetailSchema),
metadata: z.record(
z.object({
avatar: z.string(),
search_index: z.array(z.string()),
name: z.string(),
})
),
@@ -28,6 +28,7 @@ export function createAffineGlobalChannel(
let client: WebsocketClient | null;
async function handleMessage(channelMessage: ChannelMessage) {
console.log('channelMessage', channelMessage);
const parseResult = channelMessageSchema.safeParse(channelMessage);
if (!parseResult.success) {
console.error(