@@ -428,10 +428,12 @@ export class ChatwootService {
428428 ) ;
429429
430430 if ( findParticipant ) {
431- await this . updateContact ( instance , findParticipant . id , {
432- name : body . pushName ,
433- avatar_url : picture_url . profilePictureUrl || null ,
434- } ) ;
431+ if ( ! findParticipant . name || findParticipant . name === chatId ) {
432+ await this . updateContact ( instance , findParticipant . id , {
433+ name : body . pushName ,
434+ avatar_url : picture_url . profilePictureUrl || null ,
435+ } ) ;
436+ }
435437 } else {
436438 await this . createContact (
437439 instance ,
@@ -454,13 +456,28 @@ export class ChatwootService {
454456
455457 let contact : any ;
456458 if ( body . key . fromMe ) {
457- contact = findContact ;
459+ if ( findContact ) {
460+ contact = findContact ;
461+ } else {
462+ contact = await this . createContact (
463+ instance ,
464+ chatId ,
465+ filterInbox . id ,
466+ isGroup ,
467+ nameContact ,
468+ picture_url . profilePictureUrl || null ,
469+ ) ;
470+ }
458471 } else {
459472 if ( findContact ) {
460- contact = await this . updateContact ( instance , findContact . id , {
461- name : nameContact ,
462- avatar_url : picture_url . profilePictureUrl || null ,
463- } ) ;
473+ if ( ! findContact . name || findContact . name === chatId ) {
474+ contact = await this . updateContact ( instance , findContact . id , {
475+ name : nameContact ,
476+ avatar_url : picture_url . profilePictureUrl || null ,
477+ } ) ;
478+ } else {
479+ contact = findContact ;
480+ }
464481 } else {
465482 contact = await this . createContact (
466483 instance ,
@@ -1299,8 +1316,6 @@ export class ChatwootService {
12991316 this . logger . verbose ( 'get conversation message' ) ;
13001317 const bodyMessage = await this . getConversationMessage ( body . message ) ;
13011318
1302- console . log ( 'bodyMessage' , bodyMessage , body . message ) ;
1303-
13041319 if ( ! bodyMessage && ! isMedia ) {
13051320 this . logger . warn ( 'no body message found' ) ;
13061321 return ;
0 commit comments