Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(message): type the reply forwarder by its DTO
Yudhi Armyndharis3a56bd1cd4d2
diff --git a/src/modules/message/message.service.spec.ts b/src/modules/message/message.service.spec.tsindex ba1a6a01b..f1f5dc679 100644--- a/src/modules/message/message.service.spec.ts+++ b/src/modules/message/message.service.spec.ts@@ -115,6 +115,27 @@ describe('MessageService', () => {expect(sendText).toHaveBeenCalledWith('sess-1', { chatId: '[email protected]', text: 'hi' });expect(result).toEqual({ messageId: 'wa-msg-1', timestamp: 1706868000 });});++ it('passes a reply straight through with its tag list intact', async () => {+ // This forwarder is the entry point the controller and the agent tool both call. Its parameter+ // was an inline three-field literal while the controller already handed it a fourth, so the+ // body reached the sender only because structural typing does not strip excess properties.+ const reply = jest.fn().mockResolvedValue({ messageId: 'wa-msg-2', timestamp: 1706868001 });+ const facade = new MessageService(+ repository as Repository<Message>,+ engines,+ messageProjector as unknown as MessageProjector,+ hookManager as HookManager,+ lidMappingStore as unknown as LidMappingStoreService,+ inertPacing(),+ { reply } as unknown as MessageSendService,+ );++ const body = { chatId: '[email protected]', quotedMessageId: 'Q1', text: 'hi @62811', mentions: ['[email protected]'] };+ await facade.reply('sess-1', body);++ expect(reply).toHaveBeenCalledWith('sess-1', body);+ });});// ── getMessages pagination guard ──────────────────────────────────diff --git a/src/modules/message/message.service.ts b/src/modules/message/message.service.tsindex 718b5b59b..aef529d67 100644--- a/src/modules/message/message.service.ts+++ b/src/modules/message/message.service.ts@@ -5,6 +5,7 @@ import { EngineRegistry } from '../../engine/engine-registry.service';import { MessageProjector } from '../session/message-projector.service';import { SendTextMessageDto, SendMediaMessageDto, SendAudioMessageDto, MessageResponseDto } from './dto';import { SendTemplateMessageDto } from './dto/send-template.dto';+import { ReplyMessageDto } from './dto/message-actions.dto';import { Message, MessageDirection } from './entities/message.entity';import { HookManager, applySendingGate } from '../../core/hooks';import { SendPacingService } from './send-pacing.service';@@ -193,10 +194,10 @@ export class MessageService {return this.sender.sendSticker(sessionId, dto);}- reply(- sessionId: string,- dto: { chatId: string; quotedMessageId: string; text: string },- ): Promise<MessageResponseDto> {+ // Typed by the DTO rather than an inline literal, like every sibling forwarder here. The literal+ // listed three fields while the controller already handed it a fourth, so the declaration said+ // less than what flowed through, and a non-REST caller (the agent tool) could not pass it at all.+ reply(sessionId: string, dto: ReplyMessageDto): Promise<MessageResponseDto> {return this.sender.reply(sessionId, dto);}