mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-16 04:02:54 -06:00
feat: adiciona a funcionalidade de fake call
This commit is contained in:
parent
d7ddb99fb0
commit
b80b203670
@ -55,7 +55,7 @@
|
|||||||
"@sentry/node": "^8.28.0",
|
"@sentry/node": "^8.28.0",
|
||||||
"amqplib": "^0.10.3",
|
"amqplib": "^0.10.3",
|
||||||
"axios": "^1.6.5",
|
"axios": "^1.6.5",
|
||||||
"baileys": "6.7.8",
|
"baileys": "github:fmedeiros95/Baileys",
|
||||||
"class-validator": "^0.14.1",
|
"class-validator": "^0.14.1",
|
||||||
"compression": "^1.7.4",
|
"compression": "^1.7.4",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { InstanceDto } from '@api/dto/instance.dto';
|
import { InstanceDto } from '@api/dto/instance.dto';
|
||||||
import {
|
import {
|
||||||
|
OfferCallDto,
|
||||||
SendAudioDto,
|
SendAudioDto,
|
||||||
SendButtonDto,
|
SendButtonDto,
|
||||||
SendContactDto,
|
SendContactDto,
|
||||||
@ -83,4 +84,8 @@ export class SendMessageController {
|
|||||||
public async sendStatus({ instanceName }: InstanceDto, data: SendStatusDto, file?: any) {
|
public async sendStatus({ instanceName }: InstanceDto, data: SendStatusDto, file?: any) {
|
||||||
return await this.waMonitor.waInstances[instanceName].statusMessage(data, file);
|
return await this.waMonitor.waInstances[instanceName].statusMessage(data, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async offerCall({ instanceName }: InstanceDto, data: OfferCallDto) {
|
||||||
|
return await this.waMonitor.waInstances[instanceName].offerCall(data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,11 @@ export class Metadata {
|
|||||||
encoding?: boolean;
|
encoding?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class OfferCallDto extends Metadata {
|
||||||
|
isVideo?: boolean;
|
||||||
|
callDuration?: number;
|
||||||
|
}
|
||||||
|
|
||||||
export class SendTextDto extends Metadata {
|
export class SendTextDto extends Metadata {
|
||||||
text: string;
|
text: string;
|
||||||
}
|
}
|
||||||
|
@ -555,6 +555,9 @@ export class EvolutionStartupService extends ChannelStartupService {
|
|||||||
public async fetchProfile() {
|
public async fetchProfile() {
|
||||||
throw new BadRequestException('Method not available on Evolution Channel');
|
throw new BadRequestException('Method not available on Evolution Channel');
|
||||||
}
|
}
|
||||||
|
public async offerCall() {
|
||||||
|
throw new BadRequestException('Method not available on WhatsApp Business API');
|
||||||
|
}
|
||||||
public async sendPresence() {
|
public async sendPresence() {
|
||||||
throw new BadRequestException('Method not available on Evolution Channel');
|
throw new BadRequestException('Method not available on Evolution Channel');
|
||||||
}
|
}
|
||||||
|
@ -1359,6 +1359,9 @@ export class BusinessStartupService extends ChannelStartupService {
|
|||||||
public async fetchProfile() {
|
public async fetchProfile() {
|
||||||
throw new BadRequestException('Method not available on WhatsApp Business API');
|
throw new BadRequestException('Method not available on WhatsApp Business API');
|
||||||
}
|
}
|
||||||
|
public async offerCall() {
|
||||||
|
throw new BadRequestException('Method not available on WhatsApp Business API');
|
||||||
|
}
|
||||||
public async sendPresence() {
|
public async sendPresence() {
|
||||||
throw new BadRequestException('Method not available on WhatsApp Business API');
|
throw new BadRequestException('Method not available on WhatsApp Business API');
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@ import { HandleLabelDto, LabelDto } from '@api/dto/label.dto';
|
|||||||
import {
|
import {
|
||||||
ContactMessage,
|
ContactMessage,
|
||||||
MediaMessage,
|
MediaMessage,
|
||||||
|
OfferCallDto,
|
||||||
Options,
|
Options,
|
||||||
SendAudioDto,
|
SendAudioDto,
|
||||||
SendContactDto,
|
SendContactDto,
|
||||||
@ -1670,6 +1671,25 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async offerCall({ number, callDuration }: OfferCallDto) {
|
||||||
|
const jid = this.createJid(number);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const call = await this.client.offerCall(jid);
|
||||||
|
if (callDuration) {
|
||||||
|
setTimeout(async () => {
|
||||||
|
console.log('Terminating call');
|
||||||
|
const aaa = await this.client.terminateCall(call.id, call.to);
|
||||||
|
console.log(aaa);
|
||||||
|
}, callDuration * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
return call;
|
||||||
|
} catch (error) {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async sendMessage(
|
private async sendMessage(
|
||||||
sender: string,
|
sender: string,
|
||||||
message: any,
|
message: any,
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { RouterBroker } from '@api/abstract/abstract.router';
|
import { RouterBroker } from '@api/abstract/abstract.router';
|
||||||
import {
|
import {
|
||||||
|
OfferCallDto,
|
||||||
SendAudioDto,
|
SendAudioDto,
|
||||||
SendButtonDto,
|
SendButtonDto,
|
||||||
SendContactDto,
|
SendContactDto,
|
||||||
@ -21,6 +22,7 @@ import {
|
|||||||
listMessageSchema,
|
listMessageSchema,
|
||||||
locationMessageSchema,
|
locationMessageSchema,
|
||||||
mediaMessageSchema,
|
mediaMessageSchema,
|
||||||
|
offerCallSchema,
|
||||||
pollMessageSchema,
|
pollMessageSchema,
|
||||||
reactionMessageSchema,
|
reactionMessageSchema,
|
||||||
statusMessageSchema,
|
statusMessageSchema,
|
||||||
@ -166,6 +168,16 @@ export class MessageRouter extends RouterBroker {
|
|||||||
execute: (instance, data) => sendMessageController.sendButtons(instance, data),
|
execute: (instance, data) => sendMessageController.sendButtons(instance, data),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return res.status(HttpStatus.CREATED).json(response);
|
||||||
|
})
|
||||||
|
.post(this.routerPath('offerCall'), ...guards, async (req, res) => {
|
||||||
|
const response = await this.dataValidate<OfferCallDto>({
|
||||||
|
request: req,
|
||||||
|
schema: offerCallSchema,
|
||||||
|
ClassRef: OfferCallDto,
|
||||||
|
execute: (instance, data) => sendMessageController.offerCall(instance, data),
|
||||||
|
});
|
||||||
|
|
||||||
return res.status(HttpStatus.CREATED).json(response);
|
return res.status(HttpStatus.CREATED).json(response);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,17 @@ const quotedOptionsSchema: JSONSchema7 = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const offerCallSchema: JSONSchema7 = {
|
||||||
|
$id: v4(),
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
number: { ...numberDefinition },
|
||||||
|
isVideo: { type: 'boolean', enum: [true, false] },
|
||||||
|
callDuration: { type: 'integer', minimum: 1, maximum: 15 },
|
||||||
|
},
|
||||||
|
required: ['number', 'callDuration'],
|
||||||
|
};
|
||||||
|
|
||||||
export const textMessageSchema: JSONSchema7 = {
|
export const textMessageSchema: JSONSchema7 = {
|
||||||
$id: v4(),
|
$id: v4(),
|
||||||
type: 'object',
|
type: 'object',
|
||||||
|
Loading…
Reference in New Issue
Block a user