feat: adiciona a funcionalidade de fake call

This commit is contained in:
Felipe Medeiros
2024-10-07 01:13:02 -03:00
parent d7ddb99fb0
commit b80b203670
8 changed files with 60 additions and 1 deletions

View File

@@ -555,6 +555,9 @@ export class EvolutionStartupService extends ChannelStartupService {
public async fetchProfile() {
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() {
throw new BadRequestException('Method not available on Evolution Channel');
}

View File

@@ -1359,6 +1359,9 @@ export class BusinessStartupService extends ChannelStartupService {
public async fetchProfile() {
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() {
throw new BadRequestException('Method not available on WhatsApp Business API');
}

View File

@@ -32,6 +32,7 @@ import { HandleLabelDto, LabelDto } from '@api/dto/label.dto';
import {
ContactMessage,
MediaMessage,
OfferCallDto,
Options,
SendAudioDto,
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(
sender: string,
message: any,