Compare commits

...
1 Commits
Author SHA1 Message Date
allburov 5fb5eace6e Add GET /checkNumberStatus
Release / deploy-docker (push) Waiting to run
2022-09-27 17:01:36 +07:00
2 changed files with 20 additions and 0 deletions

No files matched your search

+5
View File
@@ -11,6 +11,11 @@ export class SessionQuery {
sessionName: string = WHATSAPP_DEFAULT_SESSION_NAME;
}
export class CheckNumberStatusQuery extends SessionQuery {
@IsString()
phone: string
}
export class MessageTextQuery extends SessionQuery {
@IsString()
phone: string
+15
View File
@@ -2,6 +2,7 @@ import {Body, Controller, Get, NotImplementedException, Post, Query} from '@nest
import {ApiOperation, ApiTags} from "@nestjs/swagger";
import {
ChatRequest,
CheckNumberStatusQuery,
MessageContactVcard,
MessageFile,
MessageImage,
@@ -19,6 +20,20 @@ export class ChattingController {
constructor(private whatsappSessionManager: WhatsappSessionManager) {
}
@Get('/checkNumberStatus')
@ApiOperation({summary: 'Check number status'})
async checkNumberStatus(
@Query() request: CheckNumberStatusQuery,
) {
const whatsapp = this.whatsappSessionManager.getSession(request.sessionName)
try {
const result = await whatsapp.checkNumberStatus(ensureSuffix(request.phone))
return {numberExists: result['numberExists']}
} catch (e) {
return {numberExists: false}
}
}
@Post('/sendContactVcard')
sendContactVcard(@Body() message: MessageContactVcard) {
const whatsapp = this.whatsappSessionManager.getSession(message.sessionName)