mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-22 12:06:54 -06:00
Update chatwoot.service.ts
hotfix: bug on chatwoot sdk
This commit is contained in:
parent
7dacd752d3
commit
f41f3aaba8
@ -382,19 +382,27 @@ export class ChatwootService {
|
|||||||
this.logger.verbose('find contact in chatwoot');
|
this.logger.verbose('find contact in chatwoot');
|
||||||
let contact: any;
|
let contact: any;
|
||||||
|
|
||||||
if(isGroup) {
|
if (isGroup) {
|
||||||
contact = await client.contacts.search({
|
contact = await client.contacts.search({
|
||||||
accountId: this.provider.account_id,
|
accountId: this.provider.account_id,
|
||||||
q: query,
|
q: query,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
contact = await client.contacts.filter({
|
// contact = await client.contacts.filter({
|
||||||
accountId: this.provider.account_id,
|
// 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),
|
payload: this.getFilterPayload(query),
|
||||||
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!contact) {
|
if (!contact) {
|
||||||
this.logger.warn('contact not found');
|
this.logger.warn('contact not found');
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -444,16 +452,16 @@ export class ChatwootService {
|
|||||||
|
|
||||||
private getFilterPayload(query: string) {
|
private getFilterPayload(query: string) {
|
||||||
const payload = [];
|
const payload = [];
|
||||||
const values = this.getNumbers(query)
|
const values = this.getNumbers(query);
|
||||||
|
|
||||||
const fields = this.getSearchableFields();
|
const fields = this.getSearchableFields();
|
||||||
fields.forEach((key, index) => {
|
fields.forEach((key, index) => {
|
||||||
const queryOperator = fields.length - 1 === index ? null : 'OR';
|
const queryOperator = fields.length - 1 === index ? null : 'OR';
|
||||||
payload.push({
|
payload.push({
|
||||||
"attribute_key": key,
|
attribute_key: key,
|
||||||
"filter_operator": "contains",
|
filter_operator: 'contains',
|
||||||
"values": values,
|
values: values,
|
||||||
"query_operator": queryOperator
|
query_operator: queryOperator,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user