From 99935e116a69c6ddcb23aecdd3ac990f0455f069 Mon Sep 17 00:00:00 2001 From: yassinedorbozgithub Date: Sun, 27 Oct 2024 10:06:55 +0100 Subject: [PATCH 1/2] fix(api): missing checks --- api/src/chat/repositories/block.repository.ts | 1 + api/src/chat/services/block.service.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/api/src/chat/repositories/block.repository.ts b/api/src/chat/repositories/block.repository.ts index 5d1440d..cd395c9 100644 --- a/api/src/chat/repositories/block.repository.ts +++ b/api/src/chat/repositories/block.repository.ts @@ -53,6 +53,7 @@ export class BlockRepository extends BaseRepository< if ( block.message && 'attachment' in block.message && + block.message.attachment.payload && 'url' in block.message.attachment.payload ) { this.logger.error( diff --git a/api/src/chat/services/block.service.ts b/api/src/chat/services/block.service.ts index f7353b7..f3fb45f 100644 --- a/api/src/chat/services/block.service.ts +++ b/api/src/chat/services/block.service.ts @@ -409,6 +409,7 @@ export class BlockService extends BaseService { if ( block.message && 'attachment' in block.message && + block.message.attachment.payload && 'url' in block.message.attachment.payload ) { this.logger.error( From b59aa2b2a9295c2321dcb98785fc1614056d71c9 Mon Sep 17 00:00:00 2001 From: yassinedorbozgithub Date: Sun, 27 Oct 2024 10:07:46 +0100 Subject: [PATCH 2/2] fix(api): schema support attachment_id nullable value --- api/src/chat/validation-rules/is-message.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/chat/validation-rules/is-message.ts b/api/src/chat/validation-rules/is-message.ts index 0b11cc8..fbd1589 100644 --- a/api/src/chat/validation-rules/is-message.ts +++ b/api/src/chat/validation-rules/is-message.ts @@ -71,7 +71,7 @@ export function isValidMessage(msg: any) { .required(), payload: Joi.object().keys({ url: Joi.string().uri(), - attachment_id: Joi.string(), + attachment_id: Joi.string().allow(null), }), }), elements: Joi.boolean(),