mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-12-24 22:27:46 -06:00
Adjust search for chats, messages and contacts
This commit is contained in:
@@ -2621,15 +2621,25 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
}
|
||||
|
||||
public async getLastMessage(number: string) {
|
||||
const messages = await this.fetchMessages({
|
||||
where: {
|
||||
key: {
|
||||
remoteJid: number,
|
||||
},
|
||||
owner: this.instance.name,
|
||||
const where: any = {
|
||||
key: {
|
||||
remoteJid: number,
|
||||
},
|
||||
instanceId: this.instance.id,
|
||||
};
|
||||
|
||||
const messages = await this.prismaRepository.message.findMany({
|
||||
where,
|
||||
orderBy: {
|
||||
messageTimestamp: 'desc',
|
||||
},
|
||||
take: 1,
|
||||
});
|
||||
|
||||
if (messages.length === 0) {
|
||||
throw new NotFoundException('Messages not found');
|
||||
}
|
||||
|
||||
let lastMessage = messages.pop();
|
||||
|
||||
for (const message of messages) {
|
||||
|
||||
Reference in New Issue
Block a user