mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-23 17:08:44 -06:00
Merge pull request #393 from deivisonrpg/fix/chatwoot-validate-9-digit
Fix/chatwoot validate 9 digit
This commit is contained in:
commit
0547ff719c
@ -447,27 +447,29 @@ export class ChatwootService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private getSearchableFields() {
|
private getSearchableFields() {
|
||||||
return ['identifier', 'phone_number', 'name', 'email'];
|
return ['phone_number'];
|
||||||
}
|
}
|
||||||
|
|
||||||
private getFilterPayload(query: string) {
|
private getFilterPayload(query: string) {
|
||||||
const payload = [];
|
const filterPayload = [];
|
||||||
const values = this.getNumbers(query);
|
|
||||||
|
|
||||||
const fields = this.getSearchableFields();
|
const numbers = this.getNumbers(query);
|
||||||
fields.forEach((key, index) => {
|
const fieldsToSearch = this.getSearchableFields();
|
||||||
const queryOperator = fields.length - 1 === index ? null : 'OR';
|
|
||||||
payload.push({
|
fieldsToSearch.forEach((field, index1) => {
|
||||||
attribute_key: key,
|
numbers.forEach((number, index2) => {
|
||||||
filter_operator: 'contains',
|
const queryOperator = fieldsToSearch.length - 1 === index1 && numbers.length - 1 === index2 ? null : 'OR';
|
||||||
values: values,
|
filterPayload.push({
|
||||||
query_operator: queryOperator,
|
attribute_key: field,
|
||||||
|
filter_operator: 'equal_to',
|
||||||
|
values: [number.replace('+', '')],
|
||||||
|
query_operator: queryOperator,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
return payload;
|
return filterPayload;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async createConversation(instance: InstanceDto, body: any) {
|
public async createConversation(instance: InstanceDto, body: any) {
|
||||||
this.logger.verbose('create conversation to instance: ' + instance.instanceName);
|
this.logger.verbose('create conversation to instance: ' + instance.instanceName);
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user