mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-12-09 09:59:40 -06:00
Merge pull request #2120 from FaelN1/develop
Some checks failed
Some checks failed
fix(chat): apply where filters correctly in findContacts endpoint
This commit is contained in:
commit
d5f5b8325e
@ -490,20 +490,23 @@ export class ChannelStartupService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async fetchContacts(query: Query<Contact>) {
|
public async fetchContacts(query: Query<Contact>) {
|
||||||
const remoteJid = query?.where?.remoteJid
|
const where: any = {
|
||||||
? query?.where?.remoteJid.includes('@')
|
|
||||||
? query.where?.remoteJid
|
|
||||||
: createJid(query.where?.remoteJid)
|
|
||||||
: null;
|
|
||||||
|
|
||||||
const where = {
|
|
||||||
instanceId: this.instanceId,
|
instanceId: this.instanceId,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (remoteJid) {
|
if (query?.where?.remoteJid) {
|
||||||
|
const remoteJid = query.where.remoteJid.includes('@') ? query.where.remoteJid : createJid(query.where.remoteJid);
|
||||||
where['remoteJid'] = remoteJid;
|
where['remoteJid'] = remoteJid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (query?.where?.id) {
|
||||||
|
where['id'] = query.where.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (query?.where?.pushName) {
|
||||||
|
where['pushName'] = query.where.pushName;
|
||||||
|
}
|
||||||
|
|
||||||
const contactFindManyArgs: Prisma.ContactFindManyArgs = {
|
const contactFindManyArgs: Prisma.ContactFindManyArgs = {
|
||||||
where,
|
where,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -195,8 +195,9 @@ export const contactValidateSchema: JSONSchema7 = {
|
|||||||
_id: { type: 'string', minLength: 1 },
|
_id: { type: 'string', minLength: 1 },
|
||||||
pushName: { type: 'string', minLength: 1 },
|
pushName: { type: 'string', minLength: 1 },
|
||||||
id: { type: 'string', minLength: 1 },
|
id: { type: 'string', minLength: 1 },
|
||||||
|
remoteJid: { type: 'string', minLength: 1 },
|
||||||
},
|
},
|
||||||
...isNotEmpty('_id', 'id', 'pushName'),
|
...isNotEmpty('_id', 'id', 'pushName', 'remoteJid'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user