From 076449e5d6ab5a867988ac3d9bd6f3117d5816be Mon Sep 17 00:00:00 2001 From: OrionDesign Date: Tue, 9 Dec 2025 17:03:15 -0300 Subject: [PATCH] Refactor DecryptPollVoteDto and schema structure Updated DecryptPollVoteDto to use a nested message.key structure and moved remoteJid to the top level. Adjusted the controller and validation schema to match the new structure for consistency and clarity. --- src/api/controllers/chat.controller.ts | 6 +++++- src/api/dto/chat.dto.ts | 10 +++++----- src/validate/message.schema.ts | 18 +++++++++++------- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/api/controllers/chat.controller.ts b/src/api/controllers/chat.controller.ts index e1d2458f..c224ef92 100644 --- a/src/api/controllers/chat.controller.ts +++ b/src/api/controllers/chat.controller.ts @@ -116,6 +116,10 @@ export class ChatController { } public async decryptPollVote({ instanceName }: InstanceDto, data: DecryptPollVoteDto) { - return await this.waMonitor.waInstances[instanceName].baileysDecryptPollVote(data.pollCreationMessageKey); + const pollCreationMessageKey = { + id: data.message.key.id, + remoteJid: data.remoteJid, + }; + return await this.waMonitor.waInstances[instanceName].baileysDecryptPollVote(pollCreationMessageKey); } } diff --git a/src/api/dto/chat.dto.ts b/src/api/dto/chat.dto.ts index 1e6bcbcf..a8098729 100644 --- a/src/api/dto/chat.dto.ts +++ b/src/api/dto/chat.dto.ts @@ -129,10 +129,10 @@ export class BlockUserDto { } export class DecryptPollVoteDto { - pollCreationMessageKey: { - id: string; - remoteJid: string; - participant?: string; - fromMe?: boolean; + message: { + key: { + id: string; + }; }; + remoteJid: string; } \ No newline at end of file diff --git a/src/validate/message.schema.ts b/src/validate/message.schema.ts index 79d5cda2..aef922cd 100644 --- a/src/validate/message.schema.ts +++ b/src/validate/message.schema.ts @@ -452,16 +452,20 @@ export const decryptPollVoteSchema: JSONSchema7 = { $id: v4(), type: 'object', properties: { - pollCreationMessageKey: { + message: { type: 'object', properties: { - id: { type: 'string' }, - remoteJid: { type: 'string' }, - participant: { type: 'string' }, - fromMe: { type: 'boolean' }, + key: { + type: 'object', + properties: { + id: { type: 'string' }, + }, + required: ['id'], + }, }, - required: ['id', 'remoteJid'], + required: ['key'], }, + remoteJid: { type: 'string' }, }, - required: ['pollCreationMessageKey'], + required: ['message', 'remoteJid'], }; \ No newline at end of file