Spaces:
Runtime error
Runtime error
| import { | |
| Body, | |
| Controller, | |
| Get, | |
| Post, | |
| Query, | |
| UseInterceptors, | |
| } from '@nestjs/common'; | |
| import { ApiOperation, ApiSecurity, ApiTags } from '@nestjs/swagger'; | |
| import { ApiFileAcceptHeader } from '@waha/nestjs/ApiFileAcceptHeader'; | |
| import { | |
| QRCodeSessionParam, | |
| SessionApiParam, | |
| SessionParam, | |
| } from '@waha/nestjs/params/SessionApiParam'; | |
| import { SessionManager } from '../core/abc/manager.abc'; | |
| import { WhatsappSession } from '../core/abc/session.abc'; | |
| import { BufferResponseInterceptor } from '../nestjs/BufferResponseInterceptor'; | |
| import { | |
| QRCodeFormat, | |
| QRCodeQuery, | |
| QRCodeValue, | |
| RequestCodeRequest, | |
| } from '../structures/auth.dto'; | |
| import { Base64File } from '../structures/files.dto'; | |
| ('api_key') | |
| ('api/:session/auth') | |
| ('๐ Auth') | |
| class AuthController { | |
| constructor(private manager: SessionManager) {} | |
| ('qr') | |
| ({ | |
| summary: 'Get QR code for pairing WhatsApp API.', | |
| }) | |
| ('image/png', Base64File, QRCodeValue) | |
| (new BufferResponseInterceptor('image/png')) | |
| async getQR( | |
| session: WhatsappSession, | |
| () query: QRCodeQuery, | |
| ): Promise<Buffer | QRCodeValue> { | |
| const qr = session.getQR(); | |
| if (query.format == QRCodeFormat.RAW) { | |
| return { value: qr.raw }; | |
| } | |
| return qr.get(); | |
| } | |
| ('request-code') | |
| ({ | |
| summary: 'Request authentication code.', | |
| }) | |
| requestCode( | |
| session: WhatsappSession, | |
| () request: RequestCodeRequest, | |
| ) { | |
| return session.requestCode(request.phoneNumber, request.method, request); | |
| } | |
| } | |
| export { AuthController }; | |