From 8432cd4f8dd968f6dc07933f97c4bfc648d63142 Mon Sep 17 00:00:00 2001 From: devlikepro Date: Tue, 3 Mar 2026 18:34:40 +0700 Subject: [PATCH] [core] GET /api/{session}/contacts/{id} --- src/api/contacts.session.controller.ts | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/api/contacts.session.controller.ts b/src/api/contacts.session.controller.ts index a75693c7..401b440c 100644 --- a/src/api/contacts.session.controller.ts +++ b/src/api/contacts.session.controller.ts @@ -1,12 +1,13 @@ import { Body, Controller, + Get, Param, Put, UseGuards, UsePipes, } from '@nestjs/common'; -import { ApiOperation, ApiSecurity, ApiTags } from '@nestjs/swagger'; +import { ApiOperation, ApiParam, ApiSecurity, ApiTags } from '@nestjs/swagger'; import { PoliciesGuard } from '@waha/core/auth/policies.guard'; import { CheckPolicies } from '@waha/core/auth/policies.decorator'; import { CanSession, FromParam } from '@waha/core/auth/policies'; @@ -31,6 +32,27 @@ import { Action } from '@waha/core/auth/casl.types'; export class ContactsSessionController { constructor(private manager: SessionManager) {} + @Get('/:id') + @SessionApiParam + @ApiParam({ + name: 'id', + required: true, + type: 'string', + description: 'Contact ID', + example: '123456789@c.us', + }) + @ApiOperation({ + summary: 'Get contact basic info', + description: + 'The method always return result, even if the phone number is not registered in WhatsApp. For that - use /contacts/check-exists endpoint below.', + }) + async get( + @WorkingSessionParam session: WhatsappSession, + @Param('id') id: string, + ) { + return session.getContact({ session: session.name, contactId: id }); + } + @Put('/:chatId') @SessionApiParam @ChatIdApiParam