Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:EvolutionAPI/evolution-api into …
Browse files Browse the repository at this point in the history
…develop
  • Loading branch information
DavidsonGomes committed Oct 28, 2024
2 parents a4e7baa + e22ff6c commit 89c4c19
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/api/controllers/instance.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ export class InstanceController {
return this.waMonitor.instanceInfoById(instanceId, number);
}

return this.waMonitor.instanceInfo(instanceName);
return this.waMonitor.instanceInfo([instanceName]);
}

public async setPresence({ instanceName }: InstanceDto, data: SetPresenceDto) {
Expand Down
39 changes: 39 additions & 0 deletions src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1072,6 +1072,25 @@ export class BaileysStartupService extends ChannelStartupService {
if (settings?.groupsIgnore && received.key.remoteJid.includes('@g.us')) {
continue;
}
const existingChat = await this.prismaRepository.chat.findFirst({
where: { instanceId: this.instanceId, remoteJid: received.key.remoteJid },
});

if (!!existingChat) {
const chatToInsert = {
remoteJid: received.key.remoteJid,
instanceId: this.instanceId,
name: received.pushName || '',
unreadMessages: 0,
};

this.sendDataWebhook(Events.CHATS_UPSERT, [chatToInsert]);
if (this.configService.get<Database>('DATABASE').SAVE_DATA.CHATS) {
await this.prismaRepository.chat.create({
data: chatToInsert,
});
}
}

const messageRaw = this.prepareMessage(received);

Expand Down Expand Up @@ -1387,6 +1406,26 @@ export class BaileysStartupService extends ChannelStartupService {
await this.prismaRepository.messageUpdate.create({
data: message,
});

const existingChat = await this.prismaRepository.chat.findFirst({
where: { instanceId: this.instanceId, remoteJid: message.key.remoteJid },
});

if (!!existingChat) {
const chatToInsert = {
remoteJid: message.key.remoteJid,
instanceId: this.instanceId,
name: message.pushName || '',
unreadMessages: 0,
};

this.sendDataWebhook(Events.CHATS_UPSERT, [chatToInsert]);
if (this.configService.get<Database>('DATABASE').SAVE_DATA.CHATS) {
await this.prismaRepository.chat.create({
data: chatToInsert,
});
}
}
}
}

Expand Down

0 comments on commit 89c4c19

Please sign in to comment.