Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -177,24 +177,26 @@
return existingSourceIdsSet;
}

const formattedSourceIds = sourceIds.map((sourceId) => `WAID:${sourceId.replace('WAID:', '')}`); // Make sure the sourceId is always formatted as WAID:1234567890
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
let query: string;
if (conversationId) {
query = 'SELECT source_id FROM messages WHERE source_id = ANY($1) AND conversation_id = $2';
} else {
query = 'SELECT source_id FROM messages WHERE source_id = ANY($1)';
}

const formattedSourceIds = sourceIds.map((sourceId) => `WAID:${sourceId.replace('WAID:', '')}`);
const pgClient = postgresClient.getChatwootConnection();
const result = await pgClient.query(query, [formattedSourceIds, conversationId]);


Check failure on line 182 in src/api/integrations/chatbot/chatwoot/utils/chatwoot-import-helper.ts

View workflow job for this annotation

GitHub Actions / check-lint-and-build

Delete `······`
const params = conversationId

Check failure on line 183 in src/api/integrations/chatbot/chatwoot/utils/chatwoot-import-helper.ts

View workflow job for this annotation

GitHub Actions / check-lint-and-build

Replace `·⏎········?·[formattedSourceIds,·conversationId]·⏎········` with `·?·[formattedSourceIds,·conversationId]·`
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
Outdated
? [formattedSourceIds, conversationId]
: [formattedSourceIds];

Check failure on line 186 in src/api/integrations/chatbot/chatwoot/utils/chatwoot-import-helper.ts

View workflow job for this annotation

GitHub Actions / check-lint-and-build

Delete `······`
const query = conversationId
? 'SELECT source_id FROM messages WHERE source_id = ANY($1) AND conversation_id = $2'
: 'SELECT source_id FROM messages WHERE source_id = ANY($1)';

Check failure on line 190 in src/api/integrations/chatbot/chatwoot/utils/chatwoot-import-helper.ts

View workflow job for this annotation

GitHub Actions / check-lint-and-build

Delete `······`
const result = await pgClient.query(query, params);
for (const row of result.rows) {
existingSourceIdsSet.add(row.source_id);
}

return existingSourceIdsSet;
} catch (error) {
return null;
this.logger.error(`Error on getExistingSourceIds: ${error.toString()}`);
return new Set<string>();
}
}

Expand Down Expand Up @@ -336,7 +338,6 @@

this.deleteHistoryMessages(instance);
this.deleteRepositoryMessagesCache(instance);
return 0;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oriondesign2015 Não tem porque ter return 0 aqui. Ninguém espera retorno de importHistoryMessages

}
}

Expand Down
Loading