Merge branch 'develop' of github.com:EvolutionAPI/evolution-api into develop

This commit is contained in:
Davidson Gomes 2023-12-20 09:56:32 -03:00
commit 2797250f34
3 changed files with 22 additions and 3 deletions

View File

@ -46,7 +46,7 @@
"@figuro/chatwoot-sdk": "^1.1.16",
"@hapi/boom": "^10.0.1",
"@sentry/node": "^7.59.2",
"@whiskeysockets/baileys": "github:PurpShell/Baileys",
"@whiskeysockets/baileys": "github:PurpShell/Baileys#combined",
"amqplib": "^0.10.3",
"aws-sdk": "^2.1499.0",
"axios": "^1.3.5",

View File

@ -1028,7 +1028,7 @@ export class ChatwootService {
.replaceAll(/(?<!`)`((?!\s)([^`*]+?)(?<!\s))`(?!`)/g, '```$1```') // Substitui ` por ```
: body.content;
const senderName = body?.sender?.name;
const senderName = body?.sender?.available_name || body?.sender?.name;
const waInstance = this.waMonitor.waInstances[instance.instanceName];
this.logger.verbose('check if is a message deletion');
@ -1222,9 +1222,10 @@ export class ChatwootService {
}
private updateChatwootMessageId(message: MessageRaw, chatwootMessageId: string, instance: InstanceDto) {
if (!chatwootMessageId) {
if (!chatwootMessageId || !message?.key?.id) {
return;
}
message.chatwootMessageId = chatwootMessageId;
this.repository.message.update([message], instance.instanceName, true);
}

View File

@ -133,6 +133,9 @@ import { waMonitor } from '../whatsapp.module';
import { ChamaaiService } from './chamaai.service';
import { ChatwootService } from './chatwoot.service';
import { TypebotService } from './typebot.service';
const retryCache = {};
export class WAStartupService {
constructor(
private readonly configService: ConfigService,
@ -2040,12 +2043,27 @@ export class WAStartupService {
if (events['messages.upsert']) {
this.logger.verbose('Listening event: messages.upsert');
const payload = events['messages.upsert'];
if (payload.messages.find(a => a?.messageStubType === 2)) {
const msg = payload.messages[0];
retryCache[msg.key.id] = msg;
return;
}
this.messageHandle['messages.upsert'](payload, database, settings);
}
if (events['messages.update']) {
this.logger.verbose('Listening event: messages.update');
const payload = events['messages.update'];
payload.forEach(message => {
if (retryCache[message.key.id]) {
this.client.ev.emit("messages.upsert", {
messages: [message],
type: "notify"
});
delete retryCache[message.key.id];
return;
}
})
this.messageHandle['messages.update'](payload, database, settings);
}