File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed
src/api/integrations/chatbot/chatwoot/utils Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -177,17 +177,16 @@ class ChatwootImport {
177177 return existingSourceIdsSet ;
178178 }
179179
180+ // Ensure all sourceIds are consistently prefixed with 'WAID:' as required by downstream systems and database queries.
180181 const formattedSourceIds = sourceIds . map ( ( sourceId ) => `WAID:${ sourceId . replace ( 'WAID:' , '' ) } ` ) ;
181182 const pgClient = postgresClient . getChatwootConnection ( ) ;
182-
183- const params = conversationId
184- ? [ formattedSourceIds , conversationId ]
185- : [ formattedSourceIds ] ;
186-
183+
184+ const params = conversationId ? [ formattedSourceIds , conversationId ] : [ formattedSourceIds ] ;
185+
187186 const query = conversationId
188187 ? 'SELECT source_id FROM messages WHERE source_id = ANY($1) AND conversation_id = $2'
189188 : 'SELECT source_id FROM messages WHERE source_id = ANY($1)' ;
190-
189+
191190 const result = await pgClient . query ( query , params ) ;
192191 for ( const row of result . rows ) {
193192 existingSourceIdsSet . add ( row . source_id ) ;
You can’t perform that action at this time.
0 commit comments