Skip to content

Commit 89c4c19

Browse files
committed
Merge branch 'develop' of github.com:EvolutionAPI/evolution-api into develop
2 parents a4e7baa + e22ff6c commit 89c4c19

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

src/api/controllers/instance.controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ export class InstanceController {
382382
return this.waMonitor.instanceInfoById(instanceId, number);
383383
}
384384

385-
return this.waMonitor.instanceInfo(instanceName);
385+
return this.waMonitor.instanceInfo([instanceName]);
386386
}
387387

388388
public async setPresence({ instanceName }: InstanceDto, data: SetPresenceDto) {

src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,6 +1072,25 @@ export class BaileysStartupService extends ChannelStartupService {
10721072
if (settings?.groupsIgnore && received.key.remoteJid.includes('@g.us')) {
10731073
continue;
10741074
}
1075+
const existingChat = await this.prismaRepository.chat.findFirst({
1076+
where: { instanceId: this.instanceId, remoteJid: received.key.remoteJid },
1077+
});
1078+
1079+
if (!!existingChat) {
1080+
const chatToInsert = {
1081+
remoteJid: received.key.remoteJid,
1082+
instanceId: this.instanceId,
1083+
name: received.pushName || '',
1084+
unreadMessages: 0,
1085+
};
1086+
1087+
this.sendDataWebhook(Events.CHATS_UPSERT, [chatToInsert]);
1088+
if (this.configService.get<Database>('DATABASE').SAVE_DATA.CHATS) {
1089+
await this.prismaRepository.chat.create({
1090+
data: chatToInsert,
1091+
});
1092+
}
1093+
}
10751094

10761095
const messageRaw = this.prepareMessage(received);
10771096

@@ -1387,6 +1406,26 @@ export class BaileysStartupService extends ChannelStartupService {
13871406
await this.prismaRepository.messageUpdate.create({
13881407
data: message,
13891408
});
1409+
1410+
const existingChat = await this.prismaRepository.chat.findFirst({
1411+
where: { instanceId: this.instanceId, remoteJid: message.key.remoteJid },
1412+
});
1413+
1414+
if (!!existingChat) {
1415+
const chatToInsert = {
1416+
remoteJid: message.key.remoteJid,
1417+
instanceId: this.instanceId,
1418+
name: message.pushName || '',
1419+
unreadMessages: 0,
1420+
};
1421+
1422+
this.sendDataWebhook(Events.CHATS_UPSERT, [chatToInsert]);
1423+
if (this.configService.get<Database>('DATABASE').SAVE_DATA.CHATS) {
1424+
await this.prismaRepository.chat.create({
1425+
data: chatToInsert,
1426+
});
1427+
}
1428+
}
13901429
}
13911430
}
13921431

0 commit comments

Comments
 (0)