fix: Adjusts in env files, removed save old_messages

This commit is contained in:
Davidson Gomes 2023-07-12 14:10:24 -03:00
parent 0a4e52e663
commit ae8801dd8a
4 changed files with 14 additions and 8 deletions

View File

@ -5,6 +5,7 @@
* Adjusts in docker-compose files
* Adjusts in number validation for AR and MX numbers
* Adjusts in env files, removed save old_messages
* Fix when sending a message to a group I don't belong returns a bad request
# 1.1.5 (2023-07-12 07:17)

View File

@ -75,6 +75,8 @@ CONFIG_SESSION_PHONE_NAME=chrome # chrome | firefox | edge | opera | safari
QRCODE_LIMIT=30
# Defines an authentication type for the api
# We recommend using the apikey because it will allow you to use a custom token,
# if you use jwt, a random token will be generated and may be expired and you will have to generate a new token
AUTHENTICATION_TYPE='apikey' # jwt or 'apikey'
## Define a global apikey to access all instances.
### OBS: This key must be inserted in the request header to create an instance.

View File

@ -119,6 +119,8 @@ QRCODE:
LIMIT: 30
# Defines an authentication type for the api
# We recommend using the apikey because it will allow you to use a custom token,
# if you use jwt, a random token will be generated and may be expired and you will have to generate a new token
AUTHENTICATION:
TYPE: apikey # jwt or apikey
# Define a global apikey to access all instances

View File

@ -1186,7 +1186,6 @@ export class WAStartupService {
}
private createJid(number: string): string {
console.log(number);
this.logger.verbose('Creating jid with number: ' + number);
if (number.includes('@g.us') || number.includes('@s.whatsapp.net')) {
this.logger.verbose('Number already contains @g.us or @s.whatsapp.net');
@ -1207,7 +1206,6 @@ export class WAStartupService {
}
const formattedMXARNumber = this.formatMXOrARNumber(number);
console.log(formattedMXARNumber, number);
if (formattedMXARNumber !== number) {
this.logger.verbose(
@ -1253,7 +1251,9 @@ export class WAStartupService {
this.logger.verbose('Sending message with typing');
const jid = this.createJid(number);
const isWA = (await this.whatsappNumber({ numbers: [jid] }))[0];
const numberWA = await this.whatsappNumber({ numbers: [jid] });
const isWA = numberWA[0];
if (!isWA.exists && !isJidGroup(isWA.jid) && !isWA.jid.includes('@broadcast')) {
throw new BadRequestException(isWA);
}
@ -1263,7 +1263,9 @@ export class WAStartupService {
if (isJidGroup(sender)) {
try {
this.logger.verbose('Getting group metadata');
await this.client.groupMetadata(sender);
const metadata = await this.client.groupMetadata(sender);
console.log('metadata', metadata);
} catch (error) {
throw new NotFoundException('Group not found');
}
@ -1363,7 +1365,6 @@ export class WAStartupService {
if (sender.includes('@broadcast')) {
this.logger.verbose('Sending message');
console.log(message['status']);
return await this.client.sendMessage(
sender,
message['status'].content as unknown as AnyMessageContent,
@ -1957,11 +1958,12 @@ export class WAStartupService {
const onWhatsapp: OnWhatsAppDto[] = [];
for await (const number of data.numbers) {
console.log('number', number);
const jid = this.createJid(number);
console.log('jid', jid);
if (isJidGroup(jid)) {
const group = await this.findGroup({ groupJid: jid }, 'inner');
if (!group) throw new BadRequestException('Group not found');
onWhatsapp.push(new OnWhatsAppDto(group.id, !!group?.id, group?.subject));
} else {
const verify = await this.client.onWhatsApp(jid);
@ -1971,7 +1973,6 @@ export class WAStartupService {
if (!result) {
onWhatsapp.push(new OnWhatsAppDto(jid, false));
} else {
console.log('onWhatsapp', result);
onWhatsapp.push(new OnWhatsAppDto(result.jid, result.exists));
}
}