@@ -382,19 +382,27 @@ export class ChatwootService {
382382 this . logger . verbose ( 'find contact in chatwoot' ) ;
383383 let contact : any ;
384384
385- if ( isGroup ) {
385+ if ( isGroup ) {
386386 contact = await client . contacts . search ( {
387387 accountId : this . provider . account_id ,
388388 q : query ,
389389 } ) ;
390390 } else {
391- contact = await client . contacts . filter ( {
392- accountId : this . provider . account_id ,
393- payload : this . getFilterPayload ( query ) ,
391+ // contact = await client.contacts.filter({
392+ // accountId: this.provider.account_id,
393+ // payload: this.getFilterPayload(query),
394+ // });
395+ // hotfix for: https://github.com/EvolutionAPI/evolution-api/pull/382. waiting fix: https://github.com/figurolatam/chatwoot-sdk/pull/7
396+ contact = await chatwootRequest ( this . getClientCwConfig ( ) , {
397+ method : 'POST' ,
398+ url : `/api/v1/accounts/${ this . provider . account_id } /contacts/filter` ,
399+ body : {
400+ payload : this . getFilterPayload ( query ) ,
401+ } ,
394402 } ) ;
395403 }
396404
397- if ( ! contact ) {
405+ if ( ! contact ) {
398406 this . logger . warn ( 'contact not found' ) ;
399407 return null ;
400408 }
@@ -444,16 +452,16 @@ export class ChatwootService {
444452
445453 private getFilterPayload ( query : string ) {
446454 const payload = [ ] ;
447- const values = this . getNumbers ( query )
455+ const values = this . getNumbers ( query ) ;
448456
449457 const fields = this . getSearchableFields ( ) ;
450458 fields . forEach ( ( key , index ) => {
451459 const queryOperator = fields . length - 1 === index ? null : 'OR' ;
452460 payload . push ( {
453- " attribute_key" : key ,
454- " filter_operator" : " contains" ,
455- " values" : values ,
456- " query_operator" : queryOperator
461+ attribute_key : key ,
462+ filter_operator : ' contains' ,
463+ values : values ,
464+ query_operator : queryOperator ,
457465 } ) ;
458466 } ) ;
459467
0 commit comments