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 // BlockMessage Schema
export const objectSchema = z.object({ export const blockMessageObjectSchema = z.object({
text: z.string().max(1000).optional(), text: z.string().max(1000).optional(),
attachment: z attachment: z
.object({ .object({
type: z.nativeEnum(FileType), type: z.nativeEnum(FileType),
payload: z payload: z
.object({ .union([
url: z.string().url().optional(), z.object({ url: z.string().url() }),
id: z.string().nullable().optional(), z.object({ id: z.string().nullable() }),
}) ])
.optional(), .optional(),
}) })
.optional(), .optional(),

View File

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