Merge pull request #351 from jaison-x/cache-chatwoot

fix(chatwoot): invalidate the conversation cache if reopen_conversation is false and the conversation was resolved
This commit is contained in:
Davidson Gomes 2024-01-11 12:56:37 -03:00 committed by GitHub
commit ed51f44ee8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1037,6 +1037,17 @@ export class ChatwootService {
return null;
}
// invalidate the conversation cache if reopen_conversation is false and the conversation was resolved
if (
this.provider.reopen_conversation === false &&
body.event === 'conversation_status_changed' &&
body.status === 'resolved' &&
body.meta?.sender?.identifier
) {
const keyToDelete = `createConversation-${instance.instanceName}-${body.meta.sender.identifier}`;
this.cache.delete(keyToDelete);
}
this.logger.verbose('check if is bot');
if (
!body?.conversation ||