Skip to content

Commit 2797250

Browse files
committed
Merge branch 'develop' of github.com:EvolutionAPI/evolution-api into develop
2 parents 97b3f9b + d93a826 commit 2797250

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"@figuro/chatwoot-sdk": "^1.1.16",
4747
"@hapi/boom": "^10.0.1",
4848
"@sentry/node": "^7.59.2",
49-
"@whiskeysockets/baileys": "github:PurpShell/Baileys",
49+
"@whiskeysockets/baileys": "github:PurpShell/Baileys#combined",
5050
"amqplib": "^0.10.3",
5151
"aws-sdk": "^2.1499.0",
5252
"axios": "^1.3.5",

src/whatsapp/services/chatwoot.service.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,7 @@ export class ChatwootService {
10281028
.replaceAll(/(?<!`)`((?!\s)([^`*]+?)(?<!\s))`(?!`)/g, '```$1```') // Substitui ` por ```
10291029
: body.content;
10301030

1031-
const senderName = body?.sender?.name;
1031+
const senderName = body?.sender?.available_name || body?.sender?.name;
10321032
const waInstance = this.waMonitor.waInstances[instance.instanceName];
10331033

10341034
this.logger.verbose('check if is a message deletion');
@@ -1222,9 +1222,10 @@ export class ChatwootService {
12221222
}
12231223

12241224
private updateChatwootMessageId(message: MessageRaw, chatwootMessageId: string, instance: InstanceDto) {
1225-
if (!chatwootMessageId) {
1225+
if (!chatwootMessageId || !message?.key?.id) {
12261226
return;
12271227
}
1228+
12281229
message.chatwootMessageId = chatwootMessageId;
12291230
this.repository.message.update([message], instance.instanceName, true);
12301231
}

src/whatsapp/services/whatsapp.service.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ import { waMonitor } from '../whatsapp.module';
133133
import { ChamaaiService } from './chamaai.service';
134134
import { ChatwootService } from './chatwoot.service';
135135
import { TypebotService } from './typebot.service';
136+
137+
const retryCache = {};
138+
136139
export class WAStartupService {
137140
constructor(
138141
private readonly configService: ConfigService,
@@ -2040,12 +2043,27 @@ export class WAStartupService {
20402043
if (events['messages.upsert']) {
20412044
this.logger.verbose('Listening event: messages.upsert');
20422045
const payload = events['messages.upsert'];
2046+
if (payload.messages.find(a => a?.messageStubType === 2)) {
2047+
const msg = payload.messages[0];
2048+
retryCache[msg.key.id] = msg;
2049+
return;
2050+
}
20432051
this.messageHandle['messages.upsert'](payload, database, settings);
20442052
}
20452053

20462054
if (events['messages.update']) {
20472055
this.logger.verbose('Listening event: messages.update');
20482056
const payload = events['messages.update'];
2057+
payload.forEach(message => {
2058+
if (retryCache[message.key.id]) {
2059+
this.client.ev.emit("messages.upsert", {
2060+
messages: [message],
2061+
type: "notify"
2062+
});
2063+
delete retryCache[message.key.id];
2064+
return;
2065+
}
2066+
})
20492067
this.messageHandle['messages.update'](payload, database, settings);
20502068
}
20512069

0 commit comments

Comments
 (0)