Update chatwoot.service.ts

hotfix: bug on chatwoot sdk
This commit is contained in:
jaison-x 2024-02-01 17:31:50 -03:00
parent 7dacd752d3
commit f41f3aaba8

View File

@ -388,9 +388,17 @@ export class ChatwootService {
q: query,
});
} else {
contact = await client.contacts.filter({
accountId: this.provider.account_id,
// contact = await client.contacts.filter({
// accountId: this.provider.account_id,
// payload: this.getFilterPayload(query),
// });
// hotfix for: https://github.com/EvolutionAPI/evolution-api/pull/382. waiting fix: https://github.com/figurolatam/chatwoot-sdk/pull/7
contact = await chatwootRequest(this.getClientCwConfig(), {
method: 'POST',
url: `/api/v1/accounts/${this.provider.account_id}/contacts/filter`,
body: {
payload: this.getFilterPayload(query),
},
});
}
@ -444,16 +452,16 @@ export class ChatwootService {
private getFilterPayload(query: string) {
const payload = [];
const values = this.getNumbers(query)
const values = this.getNumbers(query);
const fields = this.getSearchableFields();
fields.forEach((key, index) => {
const queryOperator = fields.length - 1 === index ? null : 'OR';
payload.push({
"attribute_key": key,
"filter_operator": "contains",
"values": values,
"query_operator": queryOperator
attribute_key: key,
filter_operator: 'contains',
values: values,
query_operator: queryOperator,
});
});