@@ -698,34 +698,33 @@ export class ChatwootService {
698698 return null ;
699699 }
700700
701- if ( contactConversations . payload . length ) {
702- let conversation : any ;
701+ let inboxConversation = contactConversations . payload . find (
702+ ( conversation ) => conversation . inbox_id == filterInbox . id ,
703+ ) ;
704+ if ( inboxConversation ) {
703705 if ( this . provider . reopenConversation ) {
704- conversation = contactConversations . payload . find ( ( conversation ) => conversation . inbox_id == filterInbox . id ) ;
705- this . logger . verbose ( `Found conversation in reopenConversation mode: ${ JSON . stringify ( conversation ) } ` ) ;
706-
707- if ( this . provider . conversationPending && conversation . status !== 'open' ) {
708- if ( conversation ) {
709- await client . conversations . toggleStatus ( {
710- accountId : this . provider . accountId ,
711- conversationId : conversation . id ,
712- data : {
713- status : 'pending' ,
714- } ,
715- } ) ;
716- }
706+ this . logger . verbose ( `Found conversation in reopenConversation mode: ${ JSON . stringify ( inboxConversation ) } ` ) ;
707+
708+ if ( this . provider . conversationPending && inboxConversation . status !== 'open' ) {
709+ await client . conversations . toggleStatus ( {
710+ accountId : this . provider . accountId ,
711+ conversationId : inboxConversation . id ,
712+ data : {
713+ status : 'pending' ,
714+ } ,
715+ } ) ;
717716 }
718717 } else {
719- conversation = contactConversations . payload . find (
718+ inboxConversation = contactConversations . payload . find (
720719 ( conversation ) => conversation . status !== 'resolved' && conversation . inbox_id == filterInbox . id ,
721720 ) ;
722- this . logger . verbose ( `Found conversation: ${ JSON . stringify ( conversation ) } ` ) ;
721+ this . logger . verbose ( `Found conversation: ${ JSON . stringify ( inboxConversation ) } ` ) ;
723722 }
724723
725- if ( conversation ) {
726- this . logger . verbose ( `Returning existing conversation ID: ${ conversation . id } ` ) ;
727- this . cache . set ( cacheKey , conversation . id ) ;
728- return conversation . id ;
724+ if ( inboxConversation ) {
725+ this . logger . verbose ( `Returning existing conversation ID: ${ inboxConversation . id } ` ) ;
726+ this . cache . set ( cacheKey , inboxConversation . id ) ;
727+ return inboxConversation . id ;
729728 }
730729 }
731730
@@ -2199,7 +2198,7 @@ export class ChatwootService {
21992198 }
22002199 }
22012200
2202- if ( event === 'messages.edit' || event === 'send.message.update' ) {
2201+ if ( event === 'messages.edit' ) {
22032202 const editedText = `${
22042203 body ?. editedMessage ?. conversation || body ?. editedMessage ?. extendedTextMessage ?. text
22052204 } \n\n_\`${ i18next . t ( 'cw.message.edited' ) } .\`_`;
0 commit comments