mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-20 02:06:43 -06:00
fix: Prevent duplicate contact processing in ChannelStartupService
- Added a Set to track seen contact IDs, ensuring that each contact is processed only once when fetching messages. This change improves efficiency and prevents redundant database queries.
This commit is contained in:
parent
2d9ca15d74
commit
cae016f40a
@ -1333,9 +1333,14 @@ export class ChannelStartupService {
|
||||
this.logger.verbose('Searching for contacts with last message');
|
||||
const contacts = await this.repository.contact.find({ where: { owner: this.instance.name } });
|
||||
const result = [];
|
||||
const seenIds = new Set();
|
||||
|
||||
for (const contact of contacts) {
|
||||
// Buscar a última mensagem desse contato
|
||||
if (seenIds.has(contact.id)) {
|
||||
continue;
|
||||
}
|
||||
seenIds.add(contact.id);
|
||||
|
||||
const messages = await this.repository.message.find({
|
||||
where: {
|
||||
owner: this.instance.name,
|
||||
|
Loading…
Reference in New Issue
Block a user