mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-12-26 23:27:45 -06:00
Merge branch 'develop' of github.com:EvolutionAPI/evolution-api into develop
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user