mirror of
https://github.com/hexastack/hexabot
synced 2025-04-10 15:55:55 +00:00
fix: apply feedback
This commit is contained in:
parent
1b2687d84d
commit
abb90fcd12
@ -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(),
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user