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