[core][2023.1] Add checkNumberStatus for webjs engine
This commit is contained in:
1 parent
d34df18da8
commit
d72b1822cb
2 files changed
+13
-3
No files matched your search
@@ -3,6 +3,8 @@ import {ApiOperation, ApiSecurity, ApiTags} from "@nestjs/swagger";
|
||||
import {SessionManager} from "../core/abc/manager.abc";
|
||||
import {ContactQuery, ContactRequest} from "../structures/contacts.dto";
|
||||
import {SessionQuery} from "../structures/base.dto";
|
||||
import {CheckNumberStatusQuery} from "../structures/chatting.dto";
|
||||
import {WANumberExistResult} from "../structures/responses.dto";
|
||||
|
||||
@ApiSecurity('api_key')
|
||||
@Controller('api/contacts')
|
||||
@@ -12,7 +14,7 @@ export class ContactsController {
|
||||
}
|
||||
|
||||
@Get('/')
|
||||
@ApiOperation({summary: 'Get contact basic info'})
|
||||
@ApiOperation({summary: 'Get contact basic info. The method always return result, even if the phone number is not registered in WhatsApp. For that - use /check-exists endpoint below.'})
|
||||
get(@Query() query: ContactQuery) {
|
||||
const whatsapp = this.manager.getSession(query.session)
|
||||
return whatsapp.getContact(query)
|
||||
@@ -25,6 +27,13 @@ export class ContactsController {
|
||||
return whatsapp.getContacts()
|
||||
}
|
||||
|
||||
@Get('/check-exists')
|
||||
@ApiOperation({summary: 'Check phone number is registered in WhatsApp.'})
|
||||
async checkExists(@Query() request: CheckNumberStatusQuery): Promise<WANumberExistResult> {
|
||||
const whatsapp = this.manager.getSession(request.session)
|
||||
return whatsapp.checkNumberStatus(request)
|
||||
}
|
||||
|
||||
@Get('/about')
|
||||
@ApiOperation({summary: 'Gets the Contact\'s current "about" info. Returns null if you don\'t have permission to read their status.'})
|
||||
getAbout(@Query() query: ContactQuery) {
|
||||
|
||||
@@ -74,8 +74,9 @@ export class WhatsappSessionWebJSCore extends WhatsappSession {
|
||||
return await this.whatsapp.pupPage.screenshot()
|
||||
}
|
||||
|
||||
checkNumberStatus(request: CheckNumberStatusQuery): Promise<WANumberExistResult> {
|
||||
throw new NotImplementedByEngineError()
|
||||
async checkNumberStatus(request: CheckNumberStatusQuery): Promise<WANumberExistResult> {
|
||||
const exist = await this.whatsapp.isRegisteredUser(this.ensureSuffix(request.phone))
|
||||
return {numberExists: exist}
|
||||
}
|
||||
|
||||
sendText(request: MessageTextRequest) {
|
||||
|
||||
Reference in new issue
Block a user