mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-20 02:06:43 -06:00
Include identifier to contact filter in chatwoot
This commit is contained in:
parent
cc17d61016
commit
cffb673fba
@ -402,14 +402,14 @@ export class ChatwootService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!contact) {
|
if (!contact && contact?.payload?.length === 0) {
|
||||||
this.logger.warn('contact not found');
|
this.logger.warn('contact not found');
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isGroup) {
|
if (!isGroup) {
|
||||||
this.logger.verbose('return contact');
|
this.logger.verbose('return contact');
|
||||||
return this.findContactInContactList(contact.payload, query);
|
return contact.payload.length > 1 ? this.findContactInContactList(contact.payload, query) : contact.payload[0];
|
||||||
} else {
|
} else {
|
||||||
this.logger.verbose('return group');
|
this.logger.verbose('return group');
|
||||||
return contact.payload.find((contact) => contact.identifier === query);
|
return contact.payload.find((contact) => contact.identifier === query);
|
||||||
@ -447,7 +447,7 @@ export class ChatwootService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private getSearchableFields() {
|
private getSearchableFields() {
|
||||||
return ['phone_number'];
|
return ['phone_number', 'identifier'];
|
||||||
}
|
}
|
||||||
|
|
||||||
private getFilterPayload(query: string) {
|
private getFilterPayload(query: string) {
|
||||||
@ -461,7 +461,7 @@ export class ChatwootService {
|
|||||||
const queryOperator = fieldsToSearch.length - 1 === index1 && numbers.length - 1 === index2 ? null : 'OR';
|
const queryOperator = fieldsToSearch.length - 1 === index1 && numbers.length - 1 === index2 ? null : 'OR';
|
||||||
filterPayload.push({
|
filterPayload.push({
|
||||||
attribute_key: field,
|
attribute_key: field,
|
||||||
filter_operator: 'equal_to',
|
filter_operator: field == 'phone_number' ? 'equal_to' : 'contains',
|
||||||
values: [number.replace('+', '')],
|
values: [number.replace('+', '')],
|
||||||
query_operator: queryOperator,
|
query_operator: queryOperator,
|
||||||
});
|
});
|
||||||
@ -470,6 +470,7 @@ export class ChatwootService {
|
|||||||
|
|
||||||
return filterPayload;
|
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