[FIX] Fixando label handler e chats #1076
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problemas
Encontrei alguns problemas de concorrencia no Handle Label e principalmente duplicação de chats.
Soluções
Ressalvas
1. A migration com a unicidade do chat não está sendo realizada corretamente (por isso o PR está em draft)2. No startup da aplicação o handle labels sempre vai ser falho já que os chats não são criados até que o whatsapp esteja sync.3.
Por algum motivo o baileys não funciona em 100% das vezes, muitas vezes ele não chama o evento de labels association. (Sempre após o reinicio da aplicação os eventos de labels.association param de funcionar).Erro meu, o redis precisa estar configurado para que esse comportamento não ocorra.4. Por algum motivo, se eu já tiver conectado em outra instancia do whatsapp web e conectar uma nova instancia na evolution, os eventos de labels ficam inconsistentes, identifiquei o mesmo problema usando o baileys diretamente.
Edit: Este pr usa uma das ideias já feita em outro PR (#1012) recomendo mergiar ele primeiro.