Feat Reject Message If is not a valid wpp number

This commit is contained in:
Deivison Lincoln
2024-02-01 23:42:52 -03:00
parent b09546577a
commit b3adde3a7a
4 changed files with 33 additions and 2 deletions

View File

@@ -1684,6 +1684,27 @@ export class ChatwootService {
return null;
}
if (event === 'contact.is_not_in_wpp') {
const getConversation = await this.createConversation(instance, body);
if (!getConversation) {
this.logger.warn('conversation not found');
return;
}
client.messages.create({
accountId: this.provider.account_id,
conversationId: getConversation,
data: {
content: `🚨 ${i18next.t('numbernotinwhatsapp')}`,
message_type: 'incoming',
private: true,
},
});
return;
}
if (event === 'messages.upsert' || event === 'send.message') {
this.logger.verbose('event messages.upsert');

View File

@@ -2357,7 +2357,15 @@ export class WAStartupService {
const isWA = (await this.whatsappNumber({ numbers: [number] }))?.shift();
this.logger.verbose(`Exists: "${isWA.exists}" | jid: ${isWA.jid}`);
if (!isWA.exists && !isJidGroup(isWA.jid) && !isWA.jid.includes('@broadcast')) {
if (this.localChatwoot.enabled) {
const body = {
key: { remoteJid: isWA.jid },
};
this.chatwootService.eventWhatsapp('contact.is_not_in_wpp', { instanceName: this.instance.name }, body);
}
throw new BadRequestException(isWA);
}