fix: apply feedback

This commit is contained in:
abdou6666 2025-02-04 15:54:02 +01:00
parent 1b2687d84d
commit abb90fcd12
2 changed files with 8 additions and 8 deletions

View File

@ -348,17 +348,17 @@ const quickReplySchema = z
}
});
// Attachment Message Schema
export const objectSchema = z.object({
// BlockMessage Schema
export const blockMessageObjectSchema = z.object({
text: z.string().max(1000).optional(),
attachment: z
.object({
type: z.nativeEnum(FileType),
payload: z
.object({
url: z.string().url().optional(),
id: z.string().nullable().optional(),
})
.union([
z.object({ url: z.string().url() }),
z.object({ id: z.string().nullable() }),
])
.optional(),
})
.optional(),

View File

@ -15,8 +15,8 @@ import {
import {
BlockMessage,
blockMessageObjectSchema,
messageRegexSchema,
objectSchema,
textSchema,
} from '../schemas/types/message';
@ -39,7 +39,7 @@ export function isValidMessage(msg: any) {
if ('plugin' in msg) {
return true;
}
const result = objectSchema.safeParse(msg);
const result = blockMessageObjectSchema.safeParse(msg);
if (!result.success) {
console.error('Block Model: Object validation failed!', result.error);
}