mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-26 10:28:38 -06:00
ignore duplicate messages
This commit is contained in:
parent
34bcee441a
commit
5f8fedc575
@ -123,12 +123,19 @@ export class MessageRepository extends Repository {
|
|||||||
this.logger.verbose('finding messages in db');
|
this.logger.verbose('finding messages in db');
|
||||||
query = this.buildQuery(query);
|
query = this.buildQuery(query);
|
||||||
|
|
||||||
return await this.messageModel
|
return await this.messageModel.aggregate([
|
||||||
.find({ ...query.where })
|
{ $match: { ...query.where } },
|
||||||
.select(query.select || {})
|
{
|
||||||
.sort(query?.sort ?? { messageTimestamp: -1 })
|
$group: {
|
||||||
.skip(query?.skip ?? 0)
|
_id: '$key', // Replace with the unique field
|
||||||
.limit(query?.limit ?? 0);
|
doc: { $first: '$$ROOT' },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ $replaceRoot: { newRoot: '$doc' } },
|
||||||
|
{ $sort: (query?.sort as Record<string, 1 | -1>) ?? { messageTimestamp: -1 } },
|
||||||
|
{ $skip: query?.skip ?? 0 },
|
||||||
|
{ $limit: query?.limit ?? 0 },
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.logger.verbose('finding messages in store');
|
this.logger.verbose('finding messages in store');
|
||||||
|
Loading…
Reference in New Issue
Block a user