mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-12-19 11:52:20 -06:00
Compare commits
87 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b8fe5603fd | ||
|
|
762453c0e3 | ||
|
|
af1b5caa29 | ||
|
|
50b3379d88 | ||
|
|
c9ac5984ec | ||
|
|
29ba63d621 | ||
|
|
2ce64af502 | ||
|
|
28c517a3d5 | ||
|
|
18ebe27bc3 | ||
|
|
0f7a39a08f | ||
|
|
a8121d7fe6 | ||
|
|
b63b7b0b7b | ||
|
|
14ea5d959f | ||
|
|
86b2999fcf | ||
|
|
f5bd11fc19 | ||
|
|
c060d330de | ||
|
|
1e320f7904 | ||
|
|
975b3ee528 | ||
|
|
5b47bc9ef0 | ||
|
|
053a7981d1 | ||
|
|
5f1f025d65 | ||
|
|
dfb003fd72 | ||
|
|
5239e431c2 | ||
|
|
53cc6132f5 | ||
|
|
0bc1b78db9 | ||
|
|
2a9412c81a | ||
|
|
f707cf4109 | ||
|
|
410cfc8bcb | ||
|
|
f1a3fd872f | ||
|
|
fff0ca5c79 | ||
|
|
bd069200ea | ||
|
|
c898f1e62a | ||
|
|
2002e1c38d | ||
|
|
1f817df5f6 | ||
|
|
8eced6c575 | ||
|
|
afcf6eab71 | ||
|
|
9633412ef6 | ||
|
|
8034e7f587 | ||
|
|
5be01e1c18 | ||
|
|
6371773416 | ||
|
|
52230edc5c | ||
|
|
dd123c6a99 | ||
|
|
5b2a0fdcb1 | ||
|
|
9354af3bc7 | ||
|
|
f48f331d43 | ||
|
|
696261d749 | ||
|
|
0e9d036fe0 | ||
|
|
8e19fe2fb5 | ||
|
|
861b690217 | ||
|
|
f7c9541f5e | ||
|
|
05b5ae8a84 | ||
|
|
2e9c14a0a8 | ||
|
|
3350cec589 | ||
|
|
bd7a42646b | ||
|
|
2ae4ddee18 | ||
|
|
2fb6e2b209 | ||
|
|
91f869b136 | ||
|
|
1284a97625 | ||
|
|
3a5cfbf36f | ||
|
|
47b8ecd43b | ||
|
|
25ce1a4689 | ||
|
|
a5156709ab | ||
|
|
fd2d37d862 | ||
|
|
87bf433e9a | ||
|
|
b5ec79daae | ||
|
|
3b19200997 | ||
|
|
0ab040080c | ||
|
|
5719896d18 | ||
|
|
e9e1cb6ebc | ||
|
|
ceee6a7e74 | ||
|
|
ebfc6d4fa5 | ||
|
|
0d62557a15 | ||
|
|
097c09328f | ||
|
|
732103292b | ||
|
|
3191e9b450 | ||
|
|
bf88fdbb31 | ||
|
|
4c3fb5e762 | ||
|
|
e4b6f4ff0d | ||
|
|
ca0b0d4602 | ||
|
|
d7c3779ff7 | ||
|
|
f0d40eea15 | ||
|
|
68dcc1c86a | ||
|
|
f7dcab3736 | ||
|
|
2fcb476c50 | ||
|
|
44a7cd62c8 | ||
|
|
f7f0f8251b | ||
|
|
395b81a6ac |
38
.github/ISSUE_TEMPLATE/-en--bug-report.md
vendored
38
.github/ISSUE_TEMPLATE/-en--bug-report.md
vendored
@@ -1,38 +0,0 @@
|
|||||||
---
|
|
||||||
name: "[EN] Bug report"
|
|
||||||
about: Create a report to help us improve
|
|
||||||
title: "[EN][BUG]"
|
|
||||||
labels: bug
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### Title: [Brief Description of the Bug]
|
|
||||||
|
|
||||||
#### Description:
|
|
||||||
Describe in detail the problem you encountered. Include any relevant context that may help understand the origin of the bug.
|
|
||||||
|
|
||||||
#### Steps to Reproduce:
|
|
||||||
1. List the steps necessary to reproduce the problem.
|
|
||||||
2. Try to be as specific as possible.
|
|
||||||
3. If the problem occurs in a specific scenario, describe it here.
|
|
||||||
|
|
||||||
#### Expected Behavior:
|
|
||||||
Describe what you expected to happen when following the steps above.
|
|
||||||
|
|
||||||
#### Current Behavior:
|
|
||||||
Explain what actually happens when you follow the steps above.
|
|
||||||
|
|
||||||
#### Screenshots/Videos:
|
|
||||||
If possible, add screenshots or videos illustrating the problem. This can be extremely helpful in understanding the issue.
|
|
||||||
|
|
||||||
#### Environment:
|
|
||||||
- **Server:** [e.g., Ubuntu 18.04]
|
|
||||||
- **API Version:** [e.g., 1.5.4]
|
|
||||||
- **Other Hardware/Software Specifications:** [e.g., CPU, GPU]
|
|
||||||
|
|
||||||
#### Submitting Logs:
|
|
||||||
Please attach logs that may be related to the problem. If the logs contain sensitive information, consider sending them privately to one of the project maintainers.
|
|
||||||
|
|
||||||
#### Additional Notes:
|
|
||||||
Include here any other information that you think might be useful in understanding or resolving the bug.
|
|
||||||
107
.github/ISSUE_TEMPLATE/-en--bug-report.yaml
vendored
Normal file
107
.github/ISSUE_TEMPLATE/-en--bug-report.yaml
vendored
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
name: Bug Report
|
||||||
|
description: Create a report to help us improve.
|
||||||
|
labels:
|
||||||
|
- bug
|
||||||
|
- en
|
||||||
|
# - help wanted
|
||||||
|
# Automatically assign the issue to:
|
||||||
|
# assignees: DavidsonGomes
|
||||||
|
body:
|
||||||
|
- type: checkboxes
|
||||||
|
id: terms
|
||||||
|
attributes:
|
||||||
|
label: Welcome!
|
||||||
|
description: |
|
||||||
|
The issue tracker is only for reporting bugs and feature requests.
|
||||||
|
For user-related support questions, please visit:
|
||||||
|
- [Discord](https://evolution-api.com/discord)
|
||||||
|
- [WhatsApp Group](https://evolution-api.com/whatsapp)
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
**DO NOT OPEN AN ISSUE FOR GENERAL SUPPORT QUESTIONS.**
|
||||||
|
|
||||||
|
options:
|
||||||
|
- label: Yes, I have searched for similar issues on [GitHub](https://github.com/EvolutionAPI/evolution-api/issues) and found none.
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: What did you do?
|
||||||
|
description: |
|
||||||
|
How to write a good bug report?
|
||||||
|
|
||||||
|
- Respect the issue template as much as possible.
|
||||||
|
- The title should be short and descriptive.
|
||||||
|
- Explain the conditions that led you to report this issue: the context.
|
||||||
|
- The context should lead to something, an idea or problem you are facing.
|
||||||
|
- Be clear and concise.
|
||||||
|
- Format your messages to help the reader focus on what matters and understand the structure of your message, use [Markdown syntax](https://help.github.com/articles/github-flavored-markdown)
|
||||||
|
placeholder: Describe the problem you encountered in detail.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: What did you expect?
|
||||||
|
placeholder: Describe what you expected to happen.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: What did you observe instead of what you expected?
|
||||||
|
placeholder: Explain what actually happens when you follow the steps above.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Screenshots/Videos
|
||||||
|
placeholder: |
|
||||||
|
If possible, add screenshots or videos that illustrate the problem. This can be extremely helpful in understanding the issue better.
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Which version of the API are you using?
|
||||||
|
description: |
|
||||||
|
Enter the version number found in the `version` property of the **package.json**.
|
||||||
|
placeholder: Paste the version here.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: dropdown
|
||||||
|
id: select
|
||||||
|
attributes:
|
||||||
|
label: What is your environment?
|
||||||
|
options:
|
||||||
|
- Windows
|
||||||
|
- Linux
|
||||||
|
- Mac
|
||||||
|
- Docker
|
||||||
|
- Other
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Other environment specifications
|
||||||
|
placeholder: 'Hardware/Software: [e.g., CPU, GPU]'
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: If applicable, paste the log output
|
||||||
|
description: |
|
||||||
|
Please attach any logs that might be related to the issue.
|
||||||
|
If the logs contain sensitive information, consider sending them privately to one of the project maintainers.
|
||||||
|
placeholder: Paste the application log here.
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Additional Notes
|
||||||
|
description: Include any other information you think might be useful to understand or resolve the bug.
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
28
.github/ISSUE_TEMPLATE/-en--feature-request.md
vendored
28
.github/ISSUE_TEMPLATE/-en--feature-request.md
vendored
@@ -1,28 +0,0 @@
|
|||||||
---
|
|
||||||
name: "[EN] Feature request"
|
|
||||||
about: Suggest an idea for the API
|
|
||||||
title: "[EN][FEAT]"
|
|
||||||
labels: enhancement
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### Title: [Brief Description of Feature Request]
|
|
||||||
|
|
||||||
#### Detailed Description:
|
|
||||||
Clearly and in detail, describe the functionality you wish to be implemented. Explain how this fits into the context of the project.
|
|
||||||
|
|
||||||
#### Rationale:
|
|
||||||
Explain why this functionality would be useful for the project. This helps in understanding the importance and priority of the request.
|
|
||||||
|
|
||||||
#### Usage Examples:
|
|
||||||
Provide specific examples of how this feature could be used. This can include scenarios or use cases where the feature would be particularly beneficial.
|
|
||||||
|
|
||||||
#### Possible Implementations:
|
|
||||||
If you have ideas on how this feature might be implemented, please share them here. This is not mandatory but can be helpful for the development team.
|
|
||||||
|
|
||||||
#### Impact on the Project:
|
|
||||||
Discuss how this new feature could impact other parts of the project, if applicable.
|
|
||||||
|
|
||||||
#### Additional Notes:
|
|
||||||
Any other information you believe is relevant to your request.
|
|
||||||
86
.github/ISSUE_TEMPLATE/-en--feature-request.yaml
vendored
Normal file
86
.github/ISSUE_TEMPLATE/-en--feature-request.yaml
vendored
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
name: Feature Request
|
||||||
|
description: Suggest ideas for the project.
|
||||||
|
labels:
|
||||||
|
- enhancement
|
||||||
|
- en
|
||||||
|
# Automatically assign the issue to:
|
||||||
|
# assignees: DavidsonGomes
|
||||||
|
body:
|
||||||
|
- type: checkboxes
|
||||||
|
id: terms
|
||||||
|
attributes:
|
||||||
|
label: Welcome!
|
||||||
|
description: '**DO NOT OPEN FOR GENERAL SUPPORT QUESTIONS.**'
|
||||||
|
|
||||||
|
options:
|
||||||
|
- label: Yes, I have searched for similar requests on [GitHub](https://github.com/code-chat-br/whatsapp-api/issues) and found none.
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: dropdown
|
||||||
|
attributes:
|
||||||
|
label: What type of feature?
|
||||||
|
description: |
|
||||||
|
How to write a good feature request?
|
||||||
|
|
||||||
|
- Respect the issue template as much as possible.
|
||||||
|
- The title should be short and descriptive.
|
||||||
|
- Explain the conditions that led you to suggest this feature: the context.
|
||||||
|
- The context should lead to something, an idea or problem you are facing.
|
||||||
|
- Be clear and concise.
|
||||||
|
- Format your messages to help the reader focus on what matters and understand the structure of your message, use [Markdown syntax](https://help.github.com/articles/github-flavored-markdown)
|
||||||
|
options:
|
||||||
|
- Integration
|
||||||
|
- Functionality
|
||||||
|
- Endpoint
|
||||||
|
- Database adjustment
|
||||||
|
- Other
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: What is the motivation for the request?
|
||||||
|
description: |
|
||||||
|
What problem does the feature seek to solve?
|
||||||
|
Clearly and in detail describe the functionality you want to be implemented.
|
||||||
|
Explain how it fits into the context of the project.
|
||||||
|
placeholder: Detailed description
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Usage Examples
|
||||||
|
description: |
|
||||||
|
Provide specific examples of how this functionality could be used.
|
||||||
|
This can include scenarios or use cases where the feature would be particularly beneficial.
|
||||||
|
placeholder: text - image - video - flowcharts
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: How should the feature be developed?
|
||||||
|
description: |
|
||||||
|
Should it be inserted directly into the code?
|
||||||
|
Should it be built as a different application that acts as an extension of the API?
|
||||||
|
For example: a `worker`?
|
||||||
|
|
||||||
|
Discuss how this new functionality could impact other parts of the project, if applicable.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
If you have ideas on how this functionality could be implemented, please share them here.
|
||||||
|
This is not mandatory, but it can be helpful for the development team.
|
||||||
|
|
||||||
|
placeholder: Insert feature ideas here
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Additional Notes
|
||||||
|
description: Any other information you believe is relevant to your request.
|
||||||
|
placeholder: Insert your observations here.
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
38
.github/ISSUE_TEMPLATE/-pt--reportar-bug.md
vendored
38
.github/ISSUE_TEMPLATE/-pt--reportar-bug.md
vendored
@@ -1,38 +0,0 @@
|
|||||||
---
|
|
||||||
name: "[PT] Reportar bug"
|
|
||||||
about: Reportar um problema
|
|
||||||
title: "[PT][BUG]"
|
|
||||||
labels: bug
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### Título: [Breve Descrição do Bug]
|
|
||||||
|
|
||||||
#### Descrição:
|
|
||||||
Descreva detalhadamente o problema que você encontrou. Inclua qualquer contexto relevante que possa ajudar a entender a origem do bug.
|
|
||||||
|
|
||||||
#### Passos para Reproduzir:
|
|
||||||
1. Liste os passos necessários para reproduzir o problema.
|
|
||||||
2. Tente ser o mais específico possível.
|
|
||||||
3. Se o problema ocorrer em um cenário específico, descreva-o aqui.
|
|
||||||
|
|
||||||
#### Comportamento Esperado:
|
|
||||||
Descreva o que você esperava que acontecesse quando seguisse os passos acima.
|
|
||||||
|
|
||||||
#### Comportamento Atual:
|
|
||||||
Explique o que realmente acontece quando você segue os passos acima.
|
|
||||||
|
|
||||||
#### Capturas de Tela/Vídeos:
|
|
||||||
Se possível, adicione capturas de tela ou vídeos que ilustrem o problema. Isso pode ser extremamente útil para entender o problema.
|
|
||||||
|
|
||||||
#### Ambiente:
|
|
||||||
- **Servidor:** [ex: Ubuntu 18.04]
|
|
||||||
- **Versão da API:** [ex: 1.5.4]
|
|
||||||
- **Outras Especificações de Hardware/Software:** [ex: CPU, GPU]
|
|
||||||
|
|
||||||
#### Envio de Logs:
|
|
||||||
Por favor, anexe os logs que possam estar relacionados ao problema. Se os logs contiverem informações sensíveis, considere enviá-los de forma privada para um dos mantenedores do projeto.
|
|
||||||
|
|
||||||
#### Notas Adicionais:
|
|
||||||
Inclua aqui qualquer outra informação que você ache que possa ser útil para entender ou resolver o bug.
|
|
||||||
108
.github/ISSUE_TEMPLATE/-pt--reportar-bug.yaml
vendored
Normal file
108
.github/ISSUE_TEMPLATE/-pt--reportar-bug.yaml
vendored
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
name: Relatório de bug
|
||||||
|
description: Crie um relatório para nos ajudar a melhorar.
|
||||||
|
labels:
|
||||||
|
- bug
|
||||||
|
- pt-br
|
||||||
|
# - help wanted
|
||||||
|
# Atrubuir automaticamente a issue a:
|
||||||
|
# assignees: DavidsonGomes
|
||||||
|
body:
|
||||||
|
- type: checkboxes
|
||||||
|
id: termos
|
||||||
|
attributes:
|
||||||
|
label: Bem-vido!
|
||||||
|
description: |
|
||||||
|
O rastreador de problemas é apenas para relatar bugs e solicitações de recursos.
|
||||||
|
Para perguntas de suporte relacionadas ao usuário final, acesse:
|
||||||
|
- [Discord](https://evolution-api.com/discord)
|
||||||
|
- [Grupo do WhatsApp](https://evolution-api.com/whatsapp)
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
**NÃO ABRA UM PROBLEMA PARA PERGUNTAS GERAIS DE SUPORTE.**
|
||||||
|
|
||||||
|
options:
|
||||||
|
- label: Sim, pesquisei problemas semelhantes no [GitHub](https://github.com/EvolutionAPI/evolution-api/issues) e não encontrei nenhum.
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: O que você fez?
|
||||||
|
description: |
|
||||||
|
Como escrever um bom relatório de bug?
|
||||||
|
|
||||||
|
- Respeite o modelo de problema tanto quanto possível.
|
||||||
|
- O título deve ser curto e descritivo.
|
||||||
|
- Explique as condições que o levaram a reportar este problema: o contexto.
|
||||||
|
- O contexto deve levar a algo, ideia ou problema que você está enfrentando.
|
||||||
|
- Seja claro e conciso.
|
||||||
|
- Formate suas mensagens para ajudar o leitor a se concentrar no que importa e entender a estrutura da sua mensagem, use [sintaxe Markdown](https://help.github.com/articles/github-flavored-markdown)
|
||||||
|
placeholder: Descreva detalhadamente o problema que você encontrou.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: O que você esperava?
|
||||||
|
placeholder: Descreva o que você esperava que acontecesse.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: O que vc observou ao invés do que esperava?
|
||||||
|
placeholder: Explique o que realmente acontece quando você segue os passos acima.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Capturas de Tela/Vídeos
|
||||||
|
placeholder: |
|
||||||
|
Se possível, adicione capturas de tela ou vídeos que ilustrem o problema. Isso pode ser extremamente útil para entender melhor o problema.
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Qual versão da API você está usando?
|
||||||
|
description: |
|
||||||
|
Insira o número da sua versão que está na propriedade `version` do **package.json**.
|
||||||
|
placeholder: Cole aqui a versão.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: dropdown
|
||||||
|
id: select
|
||||||
|
attributes:
|
||||||
|
label: Qual é o seu ambiente?
|
||||||
|
options:
|
||||||
|
- Windows
|
||||||
|
- Linux
|
||||||
|
- Mac
|
||||||
|
- Docker
|
||||||
|
- Outro
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Outras expecificações do ambiente
|
||||||
|
placeholder: 'Hardware/Software: [ex: CPU, GPU]'
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Se aplicável, cole a saída do log
|
||||||
|
description: |
|
||||||
|
Por favor, anexe os logs que possam estar relacionados ao problema.
|
||||||
|
Se os logs contiverem informações sensíveis, considere enviá-los de forma privada para um dos mantenedores do projeto.
|
||||||
|
placeholder: Cole aqui o log da aplicação
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Notas Adicionais
|
||||||
|
description: Inclua aqui qualquer outra informação que você ache que possa ser útil para entender ou resolver o bug.
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
|
|
||||||
28
.github/ISSUE_TEMPLATE/-pt--solicitar-recurso.md
vendored
28
.github/ISSUE_TEMPLATE/-pt--solicitar-recurso.md
vendored
@@ -1,28 +0,0 @@
|
|||||||
---
|
|
||||||
name: "[PT] Solicitar recurso"
|
|
||||||
about: Sugira novos recursos para a API
|
|
||||||
title: "[PT][FEAT]"
|
|
||||||
labels: enhancement
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### Título: [Breve Descrição da Solicitação de Recurso]
|
|
||||||
|
|
||||||
#### Descrição Detalhada:
|
|
||||||
Descreva claramente e em detalhes a funcionalidade que você deseja que seja implementada. Explique como isso se encaixa no contexto do projeto.
|
|
||||||
|
|
||||||
#### Racional:
|
|
||||||
Explique por que essa funcionalidade seria útil para o projeto. Isso ajuda a entender a importância e a prioridade da solicitação.
|
|
||||||
|
|
||||||
#### Exemplos de Uso:
|
|
||||||
Forneça exemplos específicos de como essa funcionalidade poderia ser utilizada. Isso pode incluir cenários ou casos de uso onde a funcionalidade seria particularmente benéfica.
|
|
||||||
|
|
||||||
#### Possíveis Implementações:
|
|
||||||
Se você tem ideias sobre como essa funcionalidade pode ser implementada, por favor, compartilhe-as aqui. Isso não é obrigatório, mas pode ser útil para a equipe de desenvolvimento.
|
|
||||||
|
|
||||||
#### Impacto no Projeto:
|
|
||||||
Discuta como essa nova funcionalidade poderia impactar outras partes do projeto, se aplicável.
|
|
||||||
|
|
||||||
#### Notas Adicionais:
|
|
||||||
Qualquer outra informação que você acredita ser relevante para a sua solicitação.
|
|
||||||
86
.github/ISSUE_TEMPLATE/-pt--solicitar-recurso.yaml
vendored
Normal file
86
.github/ISSUE_TEMPLATE/-pt--solicitar-recurso.yaml
vendored
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
name: Solicitação de recursos
|
||||||
|
description: Sugira ideias para o projeto.
|
||||||
|
labels:
|
||||||
|
- enhancement
|
||||||
|
- pt-br
|
||||||
|
# Automatically assign the issue to:
|
||||||
|
# assignees: DavidsonGomes
|
||||||
|
body:
|
||||||
|
- type: checkboxes
|
||||||
|
id: termos
|
||||||
|
attributes:
|
||||||
|
label: Bem-vindo!
|
||||||
|
description: '**NÃO ABRA PARA PERGUNTAS GERAIS DE SUPORTE.**'
|
||||||
|
|
||||||
|
options:
|
||||||
|
- label: Sim, pesquisei solicitações semelhantes no [GitHub](https://github.com/code-chat-br/whatsapp-api/issues) e não encontrei nenhum.
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: dropdown
|
||||||
|
attributes:
|
||||||
|
label: Qual tipo de recurso?
|
||||||
|
description: |
|
||||||
|
Como escrever uma boa solicitação de bug?
|
||||||
|
|
||||||
|
- Respeite o modelo de problema tanto quanto possível.
|
||||||
|
- O título deve ser curto e descritivo.
|
||||||
|
- Explique as condições que o levaram a reportar este problema: o contexto.
|
||||||
|
- O contexto deve levar a algo, ideia ou problema que você está enfrentando.
|
||||||
|
- Seja claro e conciso.
|
||||||
|
- Formate suas mensagens para ajudar o leitor a se concentrar no que importa e entender a estrutura da sua mensagem, use [sintaxe Markdown](https://help.github.com/articles/github-flavored-markdown)
|
||||||
|
options:
|
||||||
|
- Integração
|
||||||
|
- Funcionalidade
|
||||||
|
- Endpoint
|
||||||
|
- Ajuste de banco de dados
|
||||||
|
- Outro
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Qual a motivação para a solicitação?
|
||||||
|
description: |
|
||||||
|
Qual problema o recurso busca resolver?
|
||||||
|
Descreva claramente e em detalhes a funcionalidade que você deseja que seja implementada.
|
||||||
|
Explique como isso se encaixa no contexto do projeto.
|
||||||
|
placeholder: Descrição detalhada
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Exemplos de Uso
|
||||||
|
description: |
|
||||||
|
Forneça exemplos específicos de como essa funcionalidade poderia ser utilizada.
|
||||||
|
Isso pode incluir cenários ou casos de uso onde a funcionalidade seria particularmente benéfica.
|
||||||
|
placeholder: texto - imagem - video - fluxogramas
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Como o recurso deve ser desenvolvido?
|
||||||
|
description: |
|
||||||
|
Deve ser inserido diretamente no código?
|
||||||
|
Deve ser construído uma aplicação diferente que atuará como uma extenção da api?
|
||||||
|
Por exemplo: um `worker`?
|
||||||
|
|
||||||
|
Discuta como essa nova funcionalidade poderia impactar outras partes do projeto, se aplicável.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Se você tem ideias sobre como essa funcionalidade pode ser implementada, por favor, compartilhe-as aqui.
|
||||||
|
Isso não é obrigatório, mas pode ser útil para a equipe de desenvolvimento.
|
||||||
|
|
||||||
|
placeholder: Insira ideias para o recurso
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Notas Adicionais
|
||||||
|
description: Qualquer outra informação que você acredita ser relevante para a sua solicitação.
|
||||||
|
placeholder: Insira aqui as sua observções.
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
43
.github/workflows/publish_docker_image.yml
vendored
43
.github/workflows/publish_docker_image.yml
vendored
@@ -2,18 +2,13 @@ name: Build Docker image
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
|
||||||
- develop
|
|
||||||
- main
|
|
||||||
tags:
|
tags:
|
||||||
- v*
|
- "*.*.*"
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build_deploy:
|
||||||
|
name: Build and Deploy
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
|
||||||
GIT_REF: ${{ github.head_ref || github.ref_name }} # ref_name to get tags/branches
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
packages: write
|
packages: write
|
||||||
@@ -21,33 +16,33 @@ jobs:
|
|||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Docker meta
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: atendai/evolution-api
|
||||||
|
tags: type=semver,pattern=v{{version}}
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v3
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: set docker tag
|
|
||||||
run: |
|
|
||||||
echo "DOCKER_TAG=ghcr.io/atendai/evolution-api:$GIT_REF" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: replace docker tag if main
|
|
||||||
if: github.ref_name == 'main'
|
|
||||||
run: |
|
|
||||||
echo "DOCKER_TAG=ghcr.io/atendai/evolution-api:latest" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Login to GitHub Container Registry
|
- name: Login to GitHub Container Registry
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
username: ${{ github.actor }}
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Build and push
|
- name: Build and push
|
||||||
uses: docker/build-push-action@v2
|
id: docker_build
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
context: .
|
|
||||||
file: ./Dockerfile
|
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ env.DOCKER_TAG }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
|
||||||
|
- name: Image digest
|
||||||
|
run: echo ${{ steps.docker_build.outputs.digest }}
|
||||||
48
.github/workflows/publish_docker_image_homolog.yml
vendored
Normal file
48
.github/workflows/publish_docker_image_homolog.yml
vendored
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
name: Build Docker image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- develop
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build_deploy:
|
||||||
|
name: Build and Deploy
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Docker meta
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: atendai/evolution-api
|
||||||
|
tags: homolog
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
id: docker_build
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
|
||||||
|
- name: Image digest
|
||||||
|
run: echo ${{ steps.docker_build.outputs.digest }}
|
||||||
48
.github/workflows/publish_docker_image_latest.yml
vendored
Normal file
48
.github/workflows/publish_docker_image_latest.yml
vendored
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
name: Build Docker image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build_deploy:
|
||||||
|
name: Build and Deploy
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Docker meta
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: atendai/evolution-api
|
||||||
|
tags: latest
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
id: docker_build
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
|
||||||
|
- name: Image digest
|
||||||
|
run: echo ${{ steps.docker_build.outputs.digest }}
|
||||||
48
.github/workflows/publish_docker_image_v2.yml
vendored
Normal file
48
.github/workflows/publish_docker_image_v2.yml
vendored
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
name: Build Docker image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- v2.0.0
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build_deploy:
|
||||||
|
name: Build and Deploy
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Docker meta
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: atendai/evolution-api
|
||||||
|
tags: v2.0.0-alpha
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
id: docker_build
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
|
||||||
|
- name: Image digest
|
||||||
|
run: echo ${{ steps.docker_build.outputs.digest }}
|
||||||
35
CHANGELOG.md
35
CHANGELOG.md
@@ -1,6 +1,39 @@
|
|||||||
|
# 1.8.2 (2024-07-03 13:50)
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
* Corretion in globall rabbitmq queue name
|
||||||
|
* Improvement in the use of mongodb database for credentials
|
||||||
|
* Fixed base64 in webhook for documentWithCaption
|
||||||
|
* Fixed Generate pairing code
|
||||||
|
|
||||||
|
# 1.8.1 (2024-06-08 21:32)
|
||||||
|
|
||||||
|
### Feature
|
||||||
|
|
||||||
|
* New method of saving sessions to a file using worker, made in partnership with [codechat](https://github.com/code-chat-br/whatsapp-api)
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
* Correction of variables breaking lines in typebot
|
||||||
|
|
||||||
|
# 1.8.0 (2024-05-27 16:10)
|
||||||
|
|
||||||
|
### Feature
|
||||||
|
|
||||||
|
* Now in the manager, when logging in with the client's apikey, the listing only shows the instance corresponding to the provided apikey (only with MongoDB)
|
||||||
|
* New global mode for rabbitmq events
|
||||||
|
* Build in docker for linux/amd64, linux/arm64 platforms
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
* Correction in message formatting when generated by AI as markdown in typebot
|
||||||
|
* Security fix in fetch instance with client key when not connected to mongodb
|
||||||
|
|
||||||
# 1.7.5 (2024-05-21 08:50)
|
# 1.7.5 (2024-05-21 08:50)
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
* Add merge_brazil_contacts function to solve nine digit in brazilian numbers
|
* Add merge_brazil_contacts function to solve nine digit in brazilian numbers
|
||||||
* Optimize ChatwootService method for updating contact
|
* Optimize ChatwootService method for updating contact
|
||||||
* Fix swagger auth
|
* Fix swagger auth
|
||||||
@@ -12,6 +45,7 @@
|
|||||||
# 1.7.4 (2024-04-28 09:46)
|
# 1.7.4 (2024-04-28 09:46)
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
* Adjusts in proxy on fetchAgent
|
* Adjusts in proxy on fetchAgent
|
||||||
* Recovering messages lost with redis cache
|
* Recovering messages lost with redis cache
|
||||||
* Log when init redis cache service
|
* Log when init redis cache service
|
||||||
@@ -22,6 +56,7 @@
|
|||||||
# 1.7.3 (2024-04-18 12:07)
|
# 1.7.3 (2024-04-18 12:07)
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
* Revert fix audio encoding
|
* Revert fix audio encoding
|
||||||
* Recovering messages lost with redis cache
|
* Recovering messages lost with redis cache
|
||||||
* Adjusts in redis for save instances
|
* Adjusts in redis for save instances
|
||||||
|
|||||||
@@ -33,10 +33,7 @@ CLEAN_STORE_CHATS=true
|
|||||||
|
|
||||||
# Permanent data storage
|
# Permanent data storage
|
||||||
DATABASE_ENABLED=false
|
DATABASE_ENABLED=false
|
||||||
DATABASE_CONNECTION_URI=mongodb://root:root@mongodb:27017/?authSource=admin &
|
DATABASE_CONNECTION_URI=mongodb://root:root@mongodb:27017/?authSource=admin&readPreference=primary&ssl=false&directConnection=true
|
||||||
readPreference=primary &
|
|
||||||
ssl=false &
|
|
||||||
directConnection=true
|
|
||||||
DATABASE_CONNECTION_DB_PREFIX_NAME=evdocker
|
DATABASE_CONNECTION_DB_PREFIX_NAME=evdocker
|
||||||
|
|
||||||
# Choose the data you want to save in the application's database or store
|
# Choose the data you want to save in the application's database or store
|
||||||
@@ -47,9 +44,33 @@ DATABASE_SAVE_DATA_CONTACTS=false
|
|||||||
DATABASE_SAVE_DATA_CHATS=false
|
DATABASE_SAVE_DATA_CHATS=false
|
||||||
|
|
||||||
RABBITMQ_ENABLED=false
|
RABBITMQ_ENABLED=false
|
||||||
RABBITMQ_RABBITMQ_MODE=global
|
|
||||||
RABBITMQ_EXCHANGE_NAME=evolution_exchange
|
|
||||||
RABBITMQ_URI=amqp://guest:guest@rabbitmq:5672
|
RABBITMQ_URI=amqp://guest:guest@rabbitmq:5672
|
||||||
|
RABBITMQ_EXCHANGE_NAME=evolution_exchange
|
||||||
|
RABBITMQ_GLOBAL_ENABLED=false
|
||||||
|
RABBITMQ_EVENTS_APPLICATION_STARTUP=false
|
||||||
|
RABBITMQ_EVENTS_QRCODE_UPDATED=true
|
||||||
|
RABBITMQ_EVENTS_MESSAGES_SET=true
|
||||||
|
RABBITMQ_EVENTS_MESSAGES_UPSERT=true
|
||||||
|
RABBITMQ_EVENTS_MESSAGES_UPDATE=true
|
||||||
|
RABBITMQ_EVENTS_MESSAGES_DELETE=true
|
||||||
|
RABBITMQ_EVENTS_SEND_MESSAGE=true
|
||||||
|
RABBITMQ_EVENTS_CONTACTS_SET=true
|
||||||
|
RABBITMQ_EVENTS_CONTACTS_UPSERT=true
|
||||||
|
RABBITMQ_EVENTS_CONTACTS_UPDATE=true
|
||||||
|
RABBITMQ_EVENTS_PRESENCE_UPDATE=true
|
||||||
|
RABBITMQ_EVENTS_CHATS_SET=true
|
||||||
|
RABBITMQ_EVENTS_CHATS_UPSERT=true
|
||||||
|
RABBITMQ_EVENTS_CHATS_UPDATE=true
|
||||||
|
RABBITMQ_EVENTS_CHATS_DELETE=true
|
||||||
|
RABBITMQ_EVENTS_GROUPS_UPSERT=true
|
||||||
|
RABBITMQ_EVENTS_GROUPS_UPDATE=true
|
||||||
|
RABBITMQ_EVENTS_GROUP_PARTICIPANTS_UPDATE=true
|
||||||
|
RABBITMQ_EVENTS_CONNECTION_UPDATE=true
|
||||||
|
RABBITMQ_EVENTS_LABELS_EDIT=true
|
||||||
|
RABBITMQ_EVENTS_LABELS_ASSOCIATION=true
|
||||||
|
RABBITMQ_EVENTS_CALL=true
|
||||||
|
RABBITMQ_EVENTS_TYPEBOT_START=false
|
||||||
|
RABBITMQ_EVENTS_TYPEBOT_CHANGE_STATUS=false
|
||||||
|
|
||||||
WEBSOCKET_ENABLED=false
|
WEBSOCKET_ENABLED=false
|
||||||
WEBSOCKET_GLOBAL_EVENTS=false
|
WEBSOCKET_GLOBAL_EVENTS=false
|
||||||
@@ -113,7 +134,7 @@ CONFIG_SESSION_PHONE_NAME=Chrome
|
|||||||
|
|
||||||
# Set qrcode display limit
|
# Set qrcode display limit
|
||||||
QRCODE_LIMIT=30
|
QRCODE_LIMIT=30
|
||||||
QRCODE_COLOR=#198754
|
QRCODE_COLOR='#198754'
|
||||||
|
|
||||||
# old | latest
|
# old | latest
|
||||||
TYPEBOT_API_VERSION=latest
|
TYPEBOT_API_VERSION=latest
|
||||||
@@ -125,7 +146,7 @@ CHATWOOT_MESSAGE_DELETE=false # false | true
|
|||||||
# If you leave this option as true, when sending a message in Chatwoot, the client's last message will be marked as read on WhatsApp.
|
# If you leave this option as true, when sending a message in Chatwoot, the client's last message will be marked as read on WhatsApp.
|
||||||
CHATWOOT_MESSAGE_READ=false # false | true
|
CHATWOOT_MESSAGE_READ=false # false | true
|
||||||
# This db connection is used to import messages from whatsapp to chatwoot database
|
# This db connection is used to import messages from whatsapp to chatwoot database
|
||||||
CHATWOOT_IMPORT_DATABASE_CONNECTION_URI=postgres://user:password@hostname:port/dbname
|
CHATWOOT_IMPORT_DATABASE_CONNECTION_URI=postgres://user:password@hostname:port/dbname?sslmode=disable
|
||||||
CHATWOOT_IMPORT_DATABASE_PLACEHOLDER_MEDIA_MESSAGE=true
|
CHATWOOT_IMPORT_DATABASE_PLACEHOLDER_MEDIA_MESSAGE=true
|
||||||
|
|
||||||
CACHE_REDIS_ENABLED=false
|
CACHE_REDIS_ENABLED=false
|
||||||
|
|||||||
32
Dockerfile
32
Dockerfile
@@ -1,6 +1,6 @@
|
|||||||
FROM node:20.7.0-alpine AS builder
|
FROM node:20.7.0-alpine AS builder
|
||||||
|
|
||||||
LABEL version="1.7.5" description="Api to control whatsapp features through http requests."
|
LABEL version="1.8.0" description="Api to control whatsapp features through http requests."
|
||||||
LABEL maintainer="Davidson Gomes" git="https://github.com/DavidsonGomes"
|
LABEL maintainer="Davidson Gomes" git="https://github.com/DavidsonGomes"
|
||||||
LABEL contact="contato@agenciadgcode.com"
|
LABEL contact="contato@agenciadgcode.com"
|
||||||
|
|
||||||
@@ -59,9 +59,35 @@ ENV DATABASE_SAVE_DATA_CONTACTS=false
|
|||||||
ENV DATABASE_SAVE_DATA_CHATS=false
|
ENV DATABASE_SAVE_DATA_CHATS=false
|
||||||
|
|
||||||
ENV RABBITMQ_ENABLED=false
|
ENV RABBITMQ_ENABLED=false
|
||||||
ENV RABBITMQ_MODE=global
|
|
||||||
ENV RABBITMQ_EXCHANGE_NAME=evolution_exchange
|
|
||||||
ENV RABBITMQ_URI=amqp://guest:guest@rabbitmq:5672
|
ENV RABBITMQ_URI=amqp://guest:guest@rabbitmq:5672
|
||||||
|
ENV RABBITMQ_EXCHANGE_NAME=evolution_exchange
|
||||||
|
ENV RABBITMQ_GLOBAL_ENABLED=false
|
||||||
|
ENV RABBITMQ_EVENTS_APPLICATION_STARTUP=false
|
||||||
|
ENV RABBITMQ_EVENTS_INSTANCE_CREATE=false
|
||||||
|
ENV RABBITMQ_EVENTS_INSTANCE_DELETE=false
|
||||||
|
ENV RABBITMQ_EVENTS_QRCODE_UPDATED=true
|
||||||
|
ENV RABBITMQ_EVENTS_MESSAGES_SET=true
|
||||||
|
ENV RABBITMQ_EVENTS_MESSAGES_UPSERT=true
|
||||||
|
ENV RABBITMQ_EVENTS_MESSAGES_UPDATE=true
|
||||||
|
ENV RABBITMQ_EVENTS_MESSAGES_DELETE=true
|
||||||
|
ENV RABBITMQ_EVENTS_SEND_MESSAGE=true
|
||||||
|
ENV RABBITMQ_EVENTS_CONTACTS_SET=true
|
||||||
|
ENV RABBITMQ_EVENTS_CONTACTS_UPSERT=true
|
||||||
|
ENV RABBITMQ_EVENTS_CONTACTS_UPDATE=true
|
||||||
|
ENV RABBITMQ_EVENTS_PRESENCE_UPDATE=true
|
||||||
|
ENV RABBITMQ_EVENTS_CHATS_SET=true
|
||||||
|
ENV RABBITMQ_EVENTS_CHATS_UPSERT=true
|
||||||
|
ENV RABBITMQ_EVENTS_CHATS_UPDATE=true
|
||||||
|
ENV RABBITMQ_EVENTS_CHATS_DELETE=true
|
||||||
|
ENV RABBITMQ_EVENTS_GROUPS_UPSERT=true
|
||||||
|
ENV RABBITMQ_EVENTS_GROUPS_UPDATE=true
|
||||||
|
ENV RABBITMQ_EVENTS_GROUP_PARTICIPANTS_UPDATE=true
|
||||||
|
ENV RABBITMQ_EVENTS_CONNECTION_UPDATE=true
|
||||||
|
ENV RABBITMQ_EVENTS_LABELS_EDIT=true
|
||||||
|
ENV RABBITMQ_EVENTS_LABELS_ASSOCIATION=true
|
||||||
|
ENV RABBITMQ_EVENTS_CALL=true
|
||||||
|
ENV RABBITMQ_EVENTS_TYPEBOT_START=false
|
||||||
|
ENV RABBITMQ_EVENTS_TYPEBOT_CHANGE_STATUS=false
|
||||||
|
|
||||||
ENV WEBSOCKET_ENABLED=false
|
ENV WEBSOCKET_ENABLED=false
|
||||||
ENV WEBSOCKET_GLOBAL_EVENTS=false
|
ENV WEBSOCKET_GLOBAL_EVENTS=false
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "evolution-api",
|
"name": "evolution-api",
|
||||||
"version": "1.7.5",
|
"version": "1.8.2",
|
||||||
"description": "Rest api for communication with WhatsApp",
|
"description": "Rest api for communication with WhatsApp",
|
||||||
"main": "./dist/src/main.js",
|
"main": "./dist/src/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -49,7 +49,7 @@
|
|||||||
"amqplib": "^0.10.3",
|
"amqplib": "^0.10.3",
|
||||||
"@aws-sdk/client-sqs": "^3.569.0",
|
"@aws-sdk/client-sqs": "^3.569.0",
|
||||||
"axios": "^1.6.5",
|
"axios": "^1.6.5",
|
||||||
"@whiskeysockets/baileys": "^6.7.2",
|
"baileys": "github:EvolutionAPI/Baileys",
|
||||||
"class-validator": "^0.14.1",
|
"class-validator": "^0.14.1",
|
||||||
"compression": "^1.7.4",
|
"compression": "^1.7.4",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
|
|||||||
@@ -1,17 +1,18 @@
|
|||||||
import { delay } from '@whiskeysockets/baileys';
|
import { delay } from 'baileys';
|
||||||
import { isURL } from 'class-validator';
|
import { isURL } from 'class-validator';
|
||||||
import EventEmitter2 from 'eventemitter2';
|
import EventEmitter2 from 'eventemitter2';
|
||||||
import { v4 } from 'uuid';
|
import { v4 } from 'uuid';
|
||||||
|
|
||||||
import { ConfigService, HttpServer, WaBusiness } from '../../config/env.config';
|
import { Auth, ConfigService, HttpServer, WaBusiness } from '../../config/env.config';
|
||||||
import { Logger } from '../../config/logger.config';
|
import { Logger } from '../../config/logger.config';
|
||||||
import { BadRequestException, InternalServerErrorException } from '../../exceptions';
|
import { BadRequestException, InternalServerErrorException, UnauthorizedException } from '../../exceptions';
|
||||||
import { InstanceDto, SetPresenceDto } from '../dto/instance.dto';
|
import { InstanceDto, SetPresenceDto } from '../dto/instance.dto';
|
||||||
import { ChatwootService } from '../integrations/chatwoot/services/chatwoot.service';
|
import { ChatwootService } from '../integrations/chatwoot/services/chatwoot.service';
|
||||||
import { RabbitmqService } from '../integrations/rabbitmq/services/rabbitmq.service';
|
import { RabbitmqService } from '../integrations/rabbitmq/services/rabbitmq.service';
|
||||||
import { SqsService } from '../integrations/sqs/services/sqs.service';
|
import { SqsService } from '../integrations/sqs/services/sqs.service';
|
||||||
import { TypebotService } from '../integrations/typebot/services/typebot.service';
|
import { TypebotService } from '../integrations/typebot/services/typebot.service';
|
||||||
import { WebsocketService } from '../integrations/websocket/services/websocket.service';
|
import { WebsocketService } from '../integrations/websocket/services/websocket.service';
|
||||||
|
import { ProviderFiles } from '../provider/sessions';
|
||||||
import { RepositoryBroker } from '../repository/repository.manager';
|
import { RepositoryBroker } from '../repository/repository.manager';
|
||||||
import { AuthService, OldToken } from '../services/auth.service';
|
import { AuthService, OldToken } from '../services/auth.service';
|
||||||
import { CacheService } from '../services/cache.service';
|
import { CacheService } from '../services/cache.service';
|
||||||
@@ -42,7 +43,8 @@ export class InstanceController {
|
|||||||
private readonly proxyService: ProxyController,
|
private readonly proxyService: ProxyController,
|
||||||
private readonly cache: CacheService,
|
private readonly cache: CacheService,
|
||||||
private readonly chatwootCache: CacheService,
|
private readonly chatwootCache: CacheService,
|
||||||
private readonly messagesLostCache: CacheService,
|
private readonly baileysCache: CacheService,
|
||||||
|
private readonly providerFiles: ProviderFiles,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
private readonly logger = new Logger(InstanceController.name);
|
private readonly logger = new Logger(InstanceController.name);
|
||||||
@@ -110,7 +112,8 @@ export class InstanceController {
|
|||||||
this.repository,
|
this.repository,
|
||||||
this.cache,
|
this.cache,
|
||||||
this.chatwootCache,
|
this.chatwootCache,
|
||||||
this.messagesLostCache,
|
this.baileysCache,
|
||||||
|
this.providerFiles,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
instance = new BaileysStartupService(
|
instance = new BaileysStartupService(
|
||||||
@@ -119,7 +122,8 @@ export class InstanceController {
|
|||||||
this.repository,
|
this.repository,
|
||||||
this.cache,
|
this.cache,
|
||||||
this.chatwootCache,
|
this.chatwootCache,
|
||||||
this.messagesLostCache,
|
this.baileysCache,
|
||||||
|
this.providerFiles,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -679,11 +683,26 @@ export class InstanceController {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public async fetchInstances({ instanceName, instanceId, number }: InstanceDto) {
|
public async fetchInstances({ instanceName, instanceId, number }: InstanceDto, key: string) {
|
||||||
if (instanceName) {
|
const env = this.configService.get<Auth>('AUTHENTICATION').API_KEY;
|
||||||
this.logger.verbose('requested fetchInstances from ' + instanceName + ' instance');
|
|
||||||
this.logger.verbose('instanceName: ' + instanceName);
|
let name = instanceName;
|
||||||
return this.waMonitor.instanceInfo(instanceName);
|
let arrayReturn = false;
|
||||||
|
|
||||||
|
if (env.KEY !== key) {
|
||||||
|
const instanceByKey = await this.repository.auth.findByKey(key);
|
||||||
|
if (instanceByKey) {
|
||||||
|
name = instanceByKey._id;
|
||||||
|
arrayReturn = true;
|
||||||
|
} else {
|
||||||
|
throw new UnauthorizedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (name) {
|
||||||
|
this.logger.verbose('requested fetchInstances from ' + name + ' instance');
|
||||||
|
this.logger.verbose('instanceName: ' + name);
|
||||||
|
return this.waMonitor.instanceInfo(name, arrayReturn);
|
||||||
} else if (instanceId || number) {
|
} else if (instanceId || number) {
|
||||||
return this.waMonitor.instanceInfoById(instanceId, number);
|
return this.waMonitor.instanceInfoById(instanceId, number);
|
||||||
}
|
}
|
||||||
@@ -734,7 +753,7 @@ export class InstanceController {
|
|||||||
this.logger.verbose('deleting instance: ' + instanceName);
|
this.logger.verbose('deleting instance: ' + instanceName);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.waMonitor.waInstances[instanceName].sendDataWebhook(Events.INSTANCE_DELETE, {
|
this.waMonitor.waInstances[instanceName]?.sendDataWebhook(Events.INSTANCE_DELETE, {
|
||||||
instanceName,
|
instanceName,
|
||||||
instanceId: (await this.repository.auth.find(instanceName))?.instanceId,
|
instanceId: (await this.repository.auth.find(instanceName))?.instanceId,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { proto, WAPresence, WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue } from '@whiskeysockets/baileys';
|
import { proto, WAPresence, WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue } from 'baileys';
|
||||||
|
|
||||||
export class OnWhatsAppDto {
|
export class OnWhatsAppDto {
|
||||||
constructor(
|
constructor(
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { WAPresence } from '@whiskeysockets/baileys';
|
import { WAPresence } from 'baileys';
|
||||||
|
|
||||||
import { ProxyDto } from './proxy.dto';
|
import { ProxyDto } from './proxy.dto';
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { proto, WAPresence } from '@whiskeysockets/baileys';
|
import { proto, WAPresence } from 'baileys';
|
||||||
|
|
||||||
export class Quoted {
|
export class Quoted {
|
||||||
key: proto.IMessageKey;
|
key: proto.IMessageKey;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { NextFunction, Request, Response } from 'express';
|
|||||||
import jwt from 'jsonwebtoken';
|
import jwt from 'jsonwebtoken';
|
||||||
|
|
||||||
import { name } from '../../../package.json';
|
import { name } from '../../../package.json';
|
||||||
import { Auth, configService } from '../../config/env.config';
|
import { Auth, configService, Database } from '../../config/env.config';
|
||||||
import { Logger } from '../../config/logger.config';
|
import { Logger } from '../../config/logger.config';
|
||||||
import { ForbiddenException, UnauthorizedException } from '../../exceptions';
|
import { ForbiddenException, UnauthorizedException } from '../../exceptions';
|
||||||
import { InstanceDto } from '../dto/instance.dto';
|
import { InstanceDto } from '../dto/instance.dto';
|
||||||
@@ -58,6 +58,11 @@ async function jwtGuard(req: Request, res: Response, next: NextFunction) {
|
|||||||
async function apikey(req: Request, _: Response, next: NextFunction) {
|
async function apikey(req: Request, _: Response, next: NextFunction) {
|
||||||
const env = configService.get<Auth>('AUTHENTICATION').API_KEY;
|
const env = configService.get<Auth>('AUTHENTICATION').API_KEY;
|
||||||
const key = req.get('apikey');
|
const key = req.get('apikey');
|
||||||
|
const db = configService.get<Database>('DATABASE');
|
||||||
|
|
||||||
|
if (!key) {
|
||||||
|
throw new UnauthorizedException();
|
||||||
|
}
|
||||||
|
|
||||||
if (env.KEY === key) {
|
if (env.KEY === key) {
|
||||||
return next();
|
return next();
|
||||||
@@ -66,12 +71,21 @@ async function apikey(req: Request, _: Response, next: NextFunction) {
|
|||||||
if ((req.originalUrl.includes('/instance/create') || req.originalUrl.includes('/instance/fetchInstances')) && !key) {
|
if ((req.originalUrl.includes('/instance/create') || req.originalUrl.includes('/instance/fetchInstances')) && !key) {
|
||||||
throw new ForbiddenException('Missing global api key', 'The global api key must be set');
|
throw new ForbiddenException('Missing global api key', 'The global api key must be set');
|
||||||
}
|
}
|
||||||
|
const param = req.params as unknown as InstanceDto;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const param = req.params as unknown as InstanceDto;
|
if (param?.instanceName) {
|
||||||
const instanceKey = await repository.auth.find(param.instanceName);
|
const instanceKey = await repository.auth.find(param.instanceName);
|
||||||
if (instanceKey.apikey === key) {
|
if (instanceKey?.apikey === key) {
|
||||||
return next();
|
return next();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (req.originalUrl.includes('/instance/fetchInstances') && db.ENABLED) {
|
||||||
|
const instanceByKey = await repository.auth.findByKey(key);
|
||||||
|
if (instanceByKey) {
|
||||||
|
return next();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(error);
|
logger.error(error);
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import ChatwootClient, {
|
|||||||
inbox,
|
inbox,
|
||||||
} from '@figuro/chatwoot-sdk';
|
} from '@figuro/chatwoot-sdk';
|
||||||
import { request as chatwootRequest } from '@figuro/chatwoot-sdk/dist/core/request';
|
import { request as chatwootRequest } from '@figuro/chatwoot-sdk/dist/core/request';
|
||||||
import { proto } from '@whiskeysockets/baileys';
|
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
import { proto } from 'baileys';
|
||||||
import FormData from 'form-data';
|
import FormData from 'form-data';
|
||||||
import { createReadStream, unlinkSync, writeFileSync } from 'fs';
|
import { createReadStream, unlinkSync, writeFileSync } from 'fs';
|
||||||
import Jimp from 'jimp';
|
import Jimp from 'jimp';
|
||||||
@@ -444,8 +444,7 @@ export class ChatwootService {
|
|||||||
const searchableFields = this.getSearchableFields();
|
const searchableFields = this.getSearchableFields();
|
||||||
|
|
||||||
// eslint-disable-next-line prettier/prettier
|
// eslint-disable-next-line prettier/prettier
|
||||||
if(contacts.length === 2 && this.getClientCwConfig().merge_brazil_contacts && query.startsWith('+55')){
|
if (contacts.length === 2 && this.getClientCwConfig().merge_brazil_contacts && query.startsWith('+55')) {
|
||||||
|
|
||||||
const contact = this.mergeBrazilianContacts(contacts);
|
const contact = this.mergeBrazilianContacts(contacts);
|
||||||
if (contact) {
|
if (contact) {
|
||||||
return contact;
|
return contact;
|
||||||
@@ -736,7 +735,12 @@ export class ChatwootService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.logger.verbose('find inbox by name');
|
this.logger.verbose('find inbox by name');
|
||||||
const findByName = inbox.payload.find((inbox) => inbox.name === this.getClientCwConfig().name_inbox);
|
let findByName = inbox.payload.find((inbox) => inbox.name === this.getClientCwConfig().name_inbox);
|
||||||
|
|
||||||
|
if (!findByName) {
|
||||||
|
findByName = inbox.payload.find((inbox) => inbox.name === this.getClientCwConfig().name_inbox.split('-cwId-')[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!findByName) {
|
if (!findByName) {
|
||||||
this.logger.warn('inbox not found');
|
this.logger.warn('inbox not found');
|
||||||
@@ -1092,6 +1096,10 @@ export class ChatwootService {
|
|||||||
return messageSent;
|
return messageSent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (type === 'image' && parsedMedia && parsedMedia?.ext === '.gif') {
|
||||||
|
type = 'document';
|
||||||
|
}
|
||||||
|
|
||||||
this.logger.verbose('send media to instance: ' + waInstance.instanceName);
|
this.logger.verbose('send media to instance: ' + waInstance.instanceName);
|
||||||
const data: SendMediaDto = {
|
const data: SendMediaDto = {
|
||||||
number: number,
|
number: number,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { inbox } from '@figuro/chatwoot-sdk';
|
import { inbox } from '@figuro/chatwoot-sdk';
|
||||||
import { proto } from '@whiskeysockets/baileys';
|
import { proto } from 'baileys';
|
||||||
|
|
||||||
import { InstanceDto } from '../../../../api/dto/instance.dto';
|
import { InstanceDto } from '../../../../api/dto/instance.dto';
|
||||||
import { ChatwootRaw, ContactRaw, MessageRaw } from '../../../../api/models';
|
import { ChatwootRaw, ContactRaw, MessageRaw } from '../../../../api/models';
|
||||||
|
|||||||
@@ -42,6 +42,41 @@ export const getAMQP = (): amqp.Channel | null => {
|
|||||||
return amqpChannel;
|
return amqpChannel;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const initGlobalQueues = () => {
|
||||||
|
logger.info('Initializing global queues');
|
||||||
|
const events = configService.get<Rabbitmq>('RABBITMQ').EVENTS;
|
||||||
|
|
||||||
|
if (!events) {
|
||||||
|
logger.warn('No events to initialize on AMQP');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const eventKeys = Object.keys(events);
|
||||||
|
|
||||||
|
eventKeys.forEach((event) => {
|
||||||
|
if (events[event] === false) return;
|
||||||
|
|
||||||
|
const queueName = `${event.replace(/_/g, '.').toLowerCase()}`;
|
||||||
|
const amqp = getAMQP();
|
||||||
|
const exchangeName = 'evolution_exchange';
|
||||||
|
|
||||||
|
amqp.assertExchange(exchangeName, 'topic', {
|
||||||
|
durable: true,
|
||||||
|
autoDelete: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
amqp.assertQueue(queueName, {
|
||||||
|
durable: true,
|
||||||
|
autoDelete: false,
|
||||||
|
arguments: {
|
||||||
|
'x-queue-type': 'quorum',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
amqp.bindQueue(queueName, exchangeName, event);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
export const initQueues = (instanceName: string, events: string[]) => {
|
export const initQueues = (instanceName: string, events: string[]) => {
|
||||||
if (!events || !events.length) return;
|
if (!events || !events.length) return;
|
||||||
|
|
||||||
|
|||||||
@@ -519,18 +519,36 @@ export class TypebotService {
|
|||||||
text += element.text;
|
text += element.text;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (element.children && element.type !== 'a') {
|
||||||
element.children &&
|
|
||||||
(element.type === 'p' ||
|
|
||||||
element.type === 'a' ||
|
|
||||||
element.type === 'inline-variable' ||
|
|
||||||
element.type === 'variable')
|
|
||||||
) {
|
|
||||||
for (const child of element.children) {
|
for (const child of element.children) {
|
||||||
text += applyFormatting(child);
|
text += applyFormatting(child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (element.type === 'p' && element.type !== 'inline-variable') {
|
||||||
|
text = text.trim() + '\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (element.type === 'inline-variable') {
|
||||||
|
text = text.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (element.type === 'ol') {
|
||||||
|
text =
|
||||||
|
'\n' +
|
||||||
|
text
|
||||||
|
.split('\n')
|
||||||
|
.map((line, index) => (line ? `${index + 1}. ${line}` : ''))
|
||||||
|
.join('\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (element.type === 'li') {
|
||||||
|
text = text
|
||||||
|
.split('\n')
|
||||||
|
.map((line) => (line ? ` ${line}` : ''))
|
||||||
|
.join('\n');
|
||||||
|
}
|
||||||
|
|
||||||
let formats = '';
|
let formats = '';
|
||||||
|
|
||||||
if (element.bold) {
|
if (element.bold) {
|
||||||
@@ -568,6 +586,8 @@ export class TypebotService {
|
|||||||
|
|
||||||
formattedText = formattedText.replace(/\*\*/g, '').replace(/__/, '').replace(/~~/, '').replace(/\n$/, '');
|
formattedText = formattedText.replace(/\*\*/g, '').replace(/__/, '').replace(/~~/, '').replace(/\n$/, '');
|
||||||
|
|
||||||
|
formattedText = formattedText.replace(/\n$/, '');
|
||||||
|
|
||||||
await instance.textMessage({
|
await instance.textMessage({
|
||||||
number: remoteJid.split('@')[0],
|
number: remoteJid.split('@')[0],
|
||||||
options: {
|
options: {
|
||||||
|
|||||||
150
src/api/provider/sessions.ts
Normal file
150
src/api/provider/sessions.ts
Normal file
@@ -0,0 +1,150 @@
|
|||||||
|
import axios from 'axios';
|
||||||
|
import { execSync } from 'child_process';
|
||||||
|
|
||||||
|
import { Auth, ConfigService, ProviderSession } from '../../config/env.config';
|
||||||
|
import { Logger } from '../../config/logger.config';
|
||||||
|
|
||||||
|
type ResponseSuccess = { status: number; data?: any };
|
||||||
|
type ResponseProvider = Promise<[ResponseSuccess?, Error?]>;
|
||||||
|
|
||||||
|
export class ProviderFiles {
|
||||||
|
constructor(private readonly configService: ConfigService) {
|
||||||
|
this.baseUrl = `http://${this.config.HOST}:${this.config.PORT}/session/${this.config.PREFIX}`;
|
||||||
|
this.globalApiToken = this.configService.get<Auth>('AUTHENTICATION').API_KEY.KEY;
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly logger = new Logger(ProviderFiles.name);
|
||||||
|
|
||||||
|
private baseUrl: string;
|
||||||
|
private globalApiToken: string;
|
||||||
|
|
||||||
|
private readonly config = Object.freeze(this.configService.get<ProviderSession>('PROVIDER'));
|
||||||
|
|
||||||
|
get isEnabled() {
|
||||||
|
return !!this.config?.ENABLED;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async onModuleInit() {
|
||||||
|
if (this.config.ENABLED) {
|
||||||
|
const url = `http://${this.config.HOST}:${this.config.PORT}`;
|
||||||
|
try {
|
||||||
|
const response = await axios.options(url + '/ping');
|
||||||
|
if (response?.data != 'pong') {
|
||||||
|
throw new Error('Offline file provider.');
|
||||||
|
}
|
||||||
|
|
||||||
|
await axios.post(`${url}/session`, { group: this.config.PREFIX }, { headers: { apikey: this.globalApiToken } });
|
||||||
|
} catch (error) {
|
||||||
|
this.logger.error(['Failed to connect to the file server', error?.message, error?.stack]);
|
||||||
|
const pid = process.pid;
|
||||||
|
execSync(`kill -9 ${pid}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async onModuleDestroy() {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
public async create(instance: string): ResponseProvider {
|
||||||
|
try {
|
||||||
|
const response = await axios.post(
|
||||||
|
`${this.baseUrl}`,
|
||||||
|
{
|
||||||
|
instance,
|
||||||
|
},
|
||||||
|
{ headers: { apikey: this.globalApiToken } },
|
||||||
|
);
|
||||||
|
return [{ status: response.status, data: response?.data }];
|
||||||
|
} catch (error) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
status: error?.response?.status,
|
||||||
|
data: error?.response?.data,
|
||||||
|
},
|
||||||
|
error,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async write(instance: string, key: string, data: any): ResponseProvider {
|
||||||
|
try {
|
||||||
|
const response = await axios.post(`${this.baseUrl}/${instance}/${key}`, data, {
|
||||||
|
headers: { apikey: this.globalApiToken },
|
||||||
|
});
|
||||||
|
return [{ status: response.status, data: response?.data }];
|
||||||
|
} catch (error) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
status: error?.response?.status,
|
||||||
|
data: error?.response?.data,
|
||||||
|
},
|
||||||
|
error,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async read(instance: string, key: string): ResponseProvider {
|
||||||
|
try {
|
||||||
|
const response = await axios.get(`${this.baseUrl}/${instance}/${key}`, {
|
||||||
|
headers: { apikey: this.globalApiToken },
|
||||||
|
});
|
||||||
|
return [{ status: response.status, data: response?.data }];
|
||||||
|
} catch (error) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
status: error?.response?.status,
|
||||||
|
data: error?.response?.data,
|
||||||
|
},
|
||||||
|
error,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async delete(instance: string, key: string): ResponseProvider {
|
||||||
|
try {
|
||||||
|
const response = await axios.delete(`${this.baseUrl}/${instance}/${key}`, {
|
||||||
|
headers: { apikey: this.globalApiToken },
|
||||||
|
});
|
||||||
|
return [{ status: response.status, data: response?.data }];
|
||||||
|
} catch (error) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
status: error?.response?.status,
|
||||||
|
data: error?.response?.data,
|
||||||
|
},
|
||||||
|
error,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async allInstances(): ResponseProvider {
|
||||||
|
try {
|
||||||
|
const response = await axios.get(`${this.baseUrl}/list-instances`, { headers: { apikey: this.globalApiToken } });
|
||||||
|
return [{ status: response.status, data: response?.data as string[] }];
|
||||||
|
} catch (error) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
status: error?.response?.status,
|
||||||
|
data: error?.response?.data,
|
||||||
|
},
|
||||||
|
error,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async removeSession(instance: string): ResponseProvider {
|
||||||
|
try {
|
||||||
|
const response = await axios.delete(`${this.baseUrl}/${instance}`, { headers: { apikey: this.globalApiToken } });
|
||||||
|
return [{ status: response.status, data: response?.data }];
|
||||||
|
} catch (error) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
status: error?.response?.status,
|
||||||
|
data: error?.response?.data,
|
||||||
|
},
|
||||||
|
error,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -68,6 +68,20 @@ export class AuthRepository extends Repository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async findByKey(key: string): Promise<AuthRaw> {
|
||||||
|
try {
|
||||||
|
this.logger.verbose('finding auth');
|
||||||
|
if (this.dbSettings.ENABLED) {
|
||||||
|
this.logger.verbose('finding auth in db');
|
||||||
|
return await this.authModel.findOne({ apikey: key });
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
|
} catch (error) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public async list(): Promise<AuthRaw[]> {
|
public async list(): Promise<AuthRaw[]> {
|
||||||
try {
|
try {
|
||||||
if (this.dbSettings.ENABLED) {
|
if (this.dbSettings.ENABLED) {
|
||||||
|
|||||||
@@ -103,13 +103,15 @@ export class InstanceRouter extends RouterBroker {
|
|||||||
logger.verbose('request body: ');
|
logger.verbose('request body: ');
|
||||||
logger.verbose(req.body);
|
logger.verbose(req.body);
|
||||||
|
|
||||||
|
const key = req.get('apikey');
|
||||||
|
|
||||||
logger.verbose('request query: ');
|
logger.verbose('request query: ');
|
||||||
logger.verbose(req.query);
|
logger.verbose(req.query);
|
||||||
const response = await this.dataValidate<InstanceDto>({
|
const response = await this.dataValidate<InstanceDto>({
|
||||||
request: req,
|
request: req,
|
||||||
schema: null,
|
schema: null,
|
||||||
ClassRef: InstanceDto,
|
ClassRef: InstanceDto,
|
||||||
execute: (instance) => instanceController.fetchInstances(instance),
|
execute: (instance) => instanceController.fetchInstances(instance, key),
|
||||||
});
|
});
|
||||||
|
|
||||||
return res.status(HttpStatus.OK).json(response);
|
return res.status(HttpStatus.OK).json(response);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { CacheEngine } from '../cache/cacheengine';
|
import { CacheEngine } from '../cache/cacheengine';
|
||||||
import { configService } from '../config/env.config';
|
import { configService, ProviderSession } from '../config/env.config';
|
||||||
import { eventEmitter } from '../config/event.config';
|
import { eventEmitter } from '../config/event.config';
|
||||||
import { Logger } from '../config/logger.config';
|
import { Logger } from '../config/logger.config';
|
||||||
import { dbserver } from '../libs/db.connect';
|
import { dbserver } from '../libs/db.connect';
|
||||||
@@ -47,6 +47,7 @@ import {
|
|||||||
WebsocketModel,
|
WebsocketModel,
|
||||||
} from './models';
|
} from './models';
|
||||||
import { LabelModel } from './models/label.model';
|
import { LabelModel } from './models/label.model';
|
||||||
|
import { ProviderFiles } from './provider/sessions';
|
||||||
import { AuthRepository } from './repository/auth.repository';
|
import { AuthRepository } from './repository/auth.repository';
|
||||||
import { ChatRepository } from './repository/chat.repository';
|
import { ChatRepository } from './repository/chat.repository';
|
||||||
import { ContactRepository } from './repository/contact.repository';
|
import { ContactRepository } from './repository/contact.repository';
|
||||||
@@ -108,7 +109,13 @@ export const repository = new RepositoryBroker(
|
|||||||
|
|
||||||
export const cache = new CacheService(new CacheEngine(configService, 'instance').getEngine());
|
export const cache = new CacheService(new CacheEngine(configService, 'instance').getEngine());
|
||||||
const chatwootCache = new CacheService(new CacheEngine(configService, ChatwootService.name).getEngine());
|
const chatwootCache = new CacheService(new CacheEngine(configService, ChatwootService.name).getEngine());
|
||||||
const messagesLostCache = new CacheService(new CacheEngine(configService, 'baileys').getEngine());
|
const baileysCache = new CacheService(new CacheEngine(configService, 'baileys').getEngine());
|
||||||
|
|
||||||
|
let providerFiles: ProviderFiles = null;
|
||||||
|
|
||||||
|
if (configService.get<ProviderSession>('PROVIDER')?.ENABLED) {
|
||||||
|
providerFiles = new ProviderFiles(configService);
|
||||||
|
}
|
||||||
|
|
||||||
export const waMonitor = new WAMonitoringService(
|
export const waMonitor = new WAMonitoringService(
|
||||||
eventEmitter,
|
eventEmitter,
|
||||||
@@ -116,7 +123,8 @@ export const waMonitor = new WAMonitoringService(
|
|||||||
repository,
|
repository,
|
||||||
cache,
|
cache,
|
||||||
chatwootCache,
|
chatwootCache,
|
||||||
messagesLostCache,
|
baileysCache,
|
||||||
|
providerFiles,
|
||||||
);
|
);
|
||||||
|
|
||||||
const authService = new AuthService(configService, waMonitor, repository);
|
const authService = new AuthService(configService, waMonitor, repository);
|
||||||
@@ -167,7 +175,8 @@ export const instanceController = new InstanceController(
|
|||||||
proxyController,
|
proxyController,
|
||||||
cache,
|
cache,
|
||||||
chatwootCache,
|
chatwootCache,
|
||||||
messagesLostCache,
|
baileysCache,
|
||||||
|
providerFiles,
|
||||||
);
|
);
|
||||||
export const sendMessageController = new SendMessageController(waMonitor);
|
export const sendMessageController = new SendMessageController(waMonitor);
|
||||||
export const chatController = new ChatController(waMonitor);
|
export const chatController = new ChatController(waMonitor);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { BufferJSON } from '@whiskeysockets/baileys';
|
import { BufferJSON } from 'baileys';
|
||||||
|
|
||||||
import { Logger } from '../../config/logger.config';
|
import { Logger } from '../../config/logger.config';
|
||||||
import { ICache } from '../abstract/abstract.cache';
|
import { ICache } from '../abstract/abstract.cache';
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { WASocket } from '@whiskeysockets/baileys';
|
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
import { WASocket } from 'baileys';
|
||||||
import { execSync } from 'child_process';
|
import { execSync } from 'child_process';
|
||||||
import { isURL } from 'class-validator';
|
import { isURL } from 'class-validator';
|
||||||
import EventEmitter2 from 'eventemitter2';
|
import EventEmitter2 from 'eventemitter2';
|
||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
Database,
|
Database,
|
||||||
HttpServer,
|
HttpServer,
|
||||||
Log,
|
Log,
|
||||||
|
Rabbitmq,
|
||||||
Sqs,
|
Sqs,
|
||||||
Webhook,
|
Webhook,
|
||||||
Websocket,
|
Websocket,
|
||||||
@@ -305,6 +306,9 @@ export class ChannelStartupService {
|
|||||||
this.localChatwoot.conversation_pending = data?.conversation_pending;
|
this.localChatwoot.conversation_pending = data?.conversation_pending;
|
||||||
this.logger.verbose(`Chatwoot conversation pending: ${this.localChatwoot.conversation_pending}`);
|
this.logger.verbose(`Chatwoot conversation pending: ${this.localChatwoot.conversation_pending}`);
|
||||||
|
|
||||||
|
this.localChatwoot.merge_brazil_contacts = data?.merge_brazil_contacts;
|
||||||
|
this.logger.verbose(`Chatwoot merge brazil contacts: ${this.localChatwoot.merge_brazil_contacts}`);
|
||||||
|
|
||||||
this.localChatwoot.import_contacts = data?.import_contacts;
|
this.localChatwoot.import_contacts = data?.import_contacts;
|
||||||
this.logger.verbose(`Chatwoot import contacts: ${this.localChatwoot.import_contacts}`);
|
this.logger.verbose(`Chatwoot import contacts: ${this.localChatwoot.import_contacts}`);
|
||||||
|
|
||||||
@@ -328,6 +332,7 @@ export class ChannelStartupService {
|
|||||||
this.logger.verbose(`Chatwoot sign delimiter: ${data.sign_delimiter}`);
|
this.logger.verbose(`Chatwoot sign delimiter: ${data.sign_delimiter}`);
|
||||||
this.logger.verbose(`Chatwoot reopen conversation: ${data.reopen_conversation}`);
|
this.logger.verbose(`Chatwoot reopen conversation: ${data.reopen_conversation}`);
|
||||||
this.logger.verbose(`Chatwoot conversation pending: ${data.conversation_pending}`);
|
this.logger.verbose(`Chatwoot conversation pending: ${data.conversation_pending}`);
|
||||||
|
this.logger.verbose(`Chatwoot merge brazil contacts: ${data.merge_brazil_contacts}`);
|
||||||
this.logger.verbose(`Chatwoot import contacts: ${data.import_contacts}`);
|
this.logger.verbose(`Chatwoot import contacts: ${data.import_contacts}`);
|
||||||
this.logger.verbose(`Chatwoot import messages: ${data.import_messages}`);
|
this.logger.verbose(`Chatwoot import messages: ${data.import_messages}`);
|
||||||
this.logger.verbose(`Chatwoot days limit import messages: ${data.days_limit_import_messages}`);
|
this.logger.verbose(`Chatwoot days limit import messages: ${data.days_limit_import_messages}`);
|
||||||
@@ -356,7 +361,7 @@ export class ChannelStartupService {
|
|||||||
this.logger.verbose(`Chatwoot sign delimiter: ${data.sign_delimiter}`);
|
this.logger.verbose(`Chatwoot sign delimiter: ${data.sign_delimiter}`);
|
||||||
this.logger.verbose(`Chatwoot reopen conversation: ${data.reopen_conversation}`);
|
this.logger.verbose(`Chatwoot reopen conversation: ${data.reopen_conversation}`);
|
||||||
this.logger.verbose(`Chatwoot conversation pending: ${data.conversation_pending}`);
|
this.logger.verbose(`Chatwoot conversation pending: ${data.conversation_pending}`);
|
||||||
this.logger.verbose(`Chatwoot merge brazilian contacts: ${data.import_contacts}`);
|
this.logger.verbose(`Chatwoot merge brazilian contacts: ${data.merge_brazil_contacts}`);
|
||||||
this.logger.verbose(`Chatwoot import contacts: ${data.import_contacts}`);
|
this.logger.verbose(`Chatwoot import contacts: ${data.import_contacts}`);
|
||||||
this.logger.verbose(`Chatwoot import messages: ${data.import_messages}`);
|
this.logger.verbose(`Chatwoot import messages: ${data.import_messages}`);
|
||||||
this.logger.verbose(`Chatwoot days limit import messages: ${data.days_limit_import_messages}`);
|
this.logger.verbose(`Chatwoot days limit import messages: ${data.days_limit_import_messages}`);
|
||||||
@@ -688,6 +693,9 @@ export class ChannelStartupService {
|
|||||||
const rabbitmqLocal = this.localRabbitmq.events;
|
const rabbitmqLocal = this.localRabbitmq.events;
|
||||||
const sqsLocal = this.localSqs.events;
|
const sqsLocal = this.localSqs.events;
|
||||||
const serverUrl = this.configService.get<HttpServer>('SERVER').URL;
|
const serverUrl = this.configService.get<HttpServer>('SERVER').URL;
|
||||||
|
const rabbitmqEnabled = this.configService.get<Rabbitmq>('RABBITMQ').ENABLED;
|
||||||
|
const rabbitmqGlobal = this.configService.get<Rabbitmq>('RABBITMQ').GLOBAL_ENABLED;
|
||||||
|
const rabbitmqEvents = this.configService.get<Rabbitmq>('RABBITMQ').EVENTS;
|
||||||
const we = event.replace(/[.-]/gm, '_').toUpperCase();
|
const we = event.replace(/[.-]/gm, '_').toUpperCase();
|
||||||
const transformedWe = we.replace(/_/gm, '-').toLowerCase();
|
const transformedWe = we.replace(/_/gm, '-').toLowerCase();
|
||||||
const tzoffset = new Date().getTimezoneOffset() * 60000; //offset in milliseconds
|
const tzoffset = new Date().getTimezoneOffset() * 60000; //offset in milliseconds
|
||||||
@@ -698,67 +706,136 @@ export class ChannelStartupService {
|
|||||||
const tokenStore = await this.repository.auth.find(this.instanceName);
|
const tokenStore = await this.repository.auth.find(this.instanceName);
|
||||||
const instanceApikey = tokenStore?.apikey || 'Apikey not found';
|
const instanceApikey = tokenStore?.apikey || 'Apikey not found';
|
||||||
|
|
||||||
if (this.localRabbitmq.enabled) {
|
if (rabbitmqEnabled) {
|
||||||
const amqp = getAMQP();
|
const amqp = getAMQP();
|
||||||
|
if (this.localRabbitmq.enabled && amqp) {
|
||||||
if (amqp) {
|
|
||||||
if (Array.isArray(rabbitmqLocal) && rabbitmqLocal.includes(we)) {
|
if (Array.isArray(rabbitmqLocal) && rabbitmqLocal.includes(we)) {
|
||||||
const exchangeName = this.instanceName ?? 'evolution_exchange';
|
const exchangeName = this.instanceName ?? 'evolution_exchange';
|
||||||
|
|
||||||
// await amqp.assertExchange(exchangeName, 'topic', {
|
let retry = 0;
|
||||||
// durable: true,
|
|
||||||
// autoDelete: false,
|
|
||||||
// });
|
|
||||||
|
|
||||||
await this.assertExchangeAsync(amqp, exchangeName, 'topic', {
|
while (retry < 3) {
|
||||||
durable: true,
|
try {
|
||||||
autoDelete: false,
|
await amqp.assertExchange(exchangeName, 'topic', {
|
||||||
});
|
durable: true,
|
||||||
|
autoDelete: false,
|
||||||
|
});
|
||||||
|
|
||||||
const queueName = `${this.instanceName}.${event}`;
|
const eventName = event.replace(/_/g, '.').toLowerCase();
|
||||||
|
|
||||||
await amqp.assertQueue(queueName, {
|
const queueName = `${this.instanceName}.${eventName}`;
|
||||||
durable: true,
|
|
||||||
autoDelete: false,
|
|
||||||
arguments: {
|
|
||||||
'x-queue-type': 'quorum',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
await amqp.bindQueue(queueName, exchangeName, event);
|
await amqp.assertQueue(queueName, {
|
||||||
|
durable: true,
|
||||||
|
autoDelete: false,
|
||||||
|
arguments: {
|
||||||
|
'x-queue-type': 'quorum',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const message = {
|
await amqp.bindQueue(queueName, exchangeName, eventName);
|
||||||
event,
|
|
||||||
instance: this.instance.name,
|
|
||||||
data,
|
|
||||||
server_url: serverUrl,
|
|
||||||
date_time: now,
|
|
||||||
sender: this.wuid,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (expose && instanceApikey) {
|
const message = {
|
||||||
message['apikey'] = instanceApikey;
|
event,
|
||||||
|
instance: this.instance.name,
|
||||||
|
data,
|
||||||
|
server_url: serverUrl,
|
||||||
|
date_time: now,
|
||||||
|
sender: this.wuid,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (expose && instanceApikey) {
|
||||||
|
message['apikey'] = instanceApikey;
|
||||||
|
}
|
||||||
|
|
||||||
|
await amqp.publish(exchangeName, event, Buffer.from(JSON.stringify(message)));
|
||||||
|
|
||||||
|
if (this.configService.get<Log>('LOG').LEVEL.includes('WEBHOOKS')) {
|
||||||
|
const logData = {
|
||||||
|
local: ChannelStartupService.name + '.sendData-RabbitMQ',
|
||||||
|
event,
|
||||||
|
instance: this.instance.name,
|
||||||
|
data,
|
||||||
|
server_url: serverUrl,
|
||||||
|
apikey: (expose && instanceApikey) || null,
|
||||||
|
date_time: now,
|
||||||
|
sender: this.wuid,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (expose && instanceApikey) {
|
||||||
|
logData['apikey'] = instanceApikey;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.logger.log(logData);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
} catch (error) {
|
||||||
|
retry++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
await amqp.publish(exchangeName, event, Buffer.from(JSON.stringify(message)));
|
if (rabbitmqGlobal && rabbitmqEvents[we] && amqp) {
|
||||||
|
const exchangeName = 'evolution_exchange';
|
||||||
|
|
||||||
if (this.configService.get<Log>('LOG').LEVEL.includes('WEBHOOKS')) {
|
let retry = 0;
|
||||||
const logData = {
|
|
||||||
local: ChannelStartupService.name + '.sendData-RabbitMQ',
|
while (retry < 3) {
|
||||||
|
try {
|
||||||
|
await amqp.assertExchange(exchangeName, 'topic', {
|
||||||
|
durable: true,
|
||||||
|
autoDelete: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
const queueName = event;
|
||||||
|
|
||||||
|
await amqp.assertQueue(queueName, {
|
||||||
|
durable: true,
|
||||||
|
autoDelete: false,
|
||||||
|
arguments: {
|
||||||
|
'x-queue-type': 'quorum',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
await amqp.bindQueue(queueName, exchangeName, event);
|
||||||
|
|
||||||
|
const message = {
|
||||||
event,
|
event,
|
||||||
instance: this.instance.name,
|
instance: this.instance.name,
|
||||||
data,
|
data,
|
||||||
server_url: serverUrl,
|
server_url: serverUrl,
|
||||||
apikey: (expose && instanceApikey) || null,
|
|
||||||
date_time: now,
|
date_time: now,
|
||||||
sender: this.wuid,
|
sender: this.wuid,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (expose && instanceApikey) {
|
if (expose && instanceApikey) {
|
||||||
logData['apikey'] = instanceApikey;
|
message['apikey'] = instanceApikey;
|
||||||
|
}
|
||||||
|
await amqp.publish(exchangeName, event, Buffer.from(JSON.stringify(message)));
|
||||||
|
|
||||||
|
if (this.configService.get<Log>('LOG').LEVEL.includes('WEBHOOKS')) {
|
||||||
|
const logData = {
|
||||||
|
local: ChannelStartupService.name + '.sendData-RabbitMQ-Global',
|
||||||
|
event,
|
||||||
|
instance: this.instance.name,
|
||||||
|
data,
|
||||||
|
server_url: serverUrl,
|
||||||
|
apikey: (expose && instanceApikey) || null,
|
||||||
|
date_time: now,
|
||||||
|
sender: this.wuid,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (expose && instanceApikey) {
|
||||||
|
logData['apikey'] = instanceApikey;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.logger.log(logData);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.logger.log(logData);
|
break;
|
||||||
|
} catch (error) {
|
||||||
|
retry++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import ffmpegPath from '@ffmpeg-installer/ffmpeg';
|
import ffmpegPath from '@ffmpeg-installer/ffmpeg';
|
||||||
import { Boom } from '@hapi/boom';
|
import { Boom } from '@hapi/boom';
|
||||||
|
import axios from 'axios';
|
||||||
import makeWASocket, {
|
import makeWASocket, {
|
||||||
AnyMessageContent,
|
AnyMessageContent,
|
||||||
BufferedEventData,
|
BufferedEventData,
|
||||||
@@ -19,6 +20,7 @@ import makeWASocket, {
|
|||||||
GroupMetadata,
|
GroupMetadata,
|
||||||
isJidBroadcast,
|
isJidBroadcast,
|
||||||
isJidGroup,
|
isJidGroup,
|
||||||
|
isJidNewsletter,
|
||||||
isJidUser,
|
isJidUser,
|
||||||
makeCacheableSignalKeyStore,
|
makeCacheableSignalKeyStore,
|
||||||
MessageUpsertType,
|
MessageUpsertType,
|
||||||
@@ -35,10 +37,9 @@ import makeWASocket, {
|
|||||||
WAMessageUpdate,
|
WAMessageUpdate,
|
||||||
WAPresence,
|
WAPresence,
|
||||||
WASocket,
|
WASocket,
|
||||||
} from '@whiskeysockets/baileys';
|
} from 'baileys';
|
||||||
import { Label } from '@whiskeysockets/baileys/lib/Types/Label';
|
import { Label } from 'baileys/lib/Types/Label';
|
||||||
import { LabelAssociation } from '@whiskeysockets/baileys/lib/Types/LabelAssociation';
|
import { LabelAssociation } from 'baileys/lib/Types/LabelAssociation';
|
||||||
import axios from 'axios';
|
|
||||||
import { exec } from 'child_process';
|
import { exec } from 'child_process';
|
||||||
import { isBase64, isURL } from 'class-validator';
|
import { isBase64, isURL } from 'class-validator';
|
||||||
import EventEmitter2 from 'eventemitter2';
|
import EventEmitter2 from 'eventemitter2';
|
||||||
@@ -55,12 +56,23 @@ import qrcode, { QRCodeToDataURLOptions } from 'qrcode';
|
|||||||
import qrcodeTerminal from 'qrcode-terminal';
|
import qrcodeTerminal from 'qrcode-terminal';
|
||||||
import sharp from 'sharp';
|
import sharp from 'sharp';
|
||||||
|
|
||||||
import { CacheConf, ConfigService, ConfigSessionPhone, Database, Log, QrCode } from '../../../config/env.config';
|
import { CacheEngine } from '../../../cache/cacheengine';
|
||||||
|
import {
|
||||||
|
CacheConf,
|
||||||
|
ConfigService,
|
||||||
|
configService,
|
||||||
|
ConfigSessionPhone,
|
||||||
|
Database,
|
||||||
|
Log,
|
||||||
|
ProviderSession,
|
||||||
|
QrCode,
|
||||||
|
} from '../../../config/env.config';
|
||||||
import { INSTANCE_DIR } from '../../../config/path.config';
|
import { INSTANCE_DIR } from '../../../config/path.config';
|
||||||
import { BadRequestException, InternalServerErrorException, NotFoundException } from '../../../exceptions';
|
import { BadRequestException, InternalServerErrorException, NotFoundException } from '../../../exceptions';
|
||||||
import { dbserver } from '../../../libs/db.connect';
|
import { dbserver } from '../../../libs/db.connect';
|
||||||
import { makeProxyAgent } from '../../../utils/makeProxyAgent';
|
import { makeProxyAgent } from '../../../utils/makeProxyAgent';
|
||||||
import { useMultiFileAuthStateDb } from '../../../utils/use-multi-file-auth-state-db';
|
import { useMultiFileAuthStateDb } from '../../../utils/use-multi-file-auth-state-db';
|
||||||
|
import { AuthStateProvider } from '../../../utils/use-multi-file-auth-state-provider-files';
|
||||||
import { useMultiFileAuthStateRedisDb } from '../../../utils/use-multi-file-auth-state-redis-db';
|
import { useMultiFileAuthStateRedisDb } from '../../../utils/use-multi-file-auth-state-redis-db';
|
||||||
import {
|
import {
|
||||||
ArchiveChatDto,
|
ArchiveChatDto,
|
||||||
@@ -114,12 +126,15 @@ import { SettingsRaw } from '../../models';
|
|||||||
import { ChatRaw } from '../../models/chat.model';
|
import { ChatRaw } from '../../models/chat.model';
|
||||||
import { ContactRaw } from '../../models/contact.model';
|
import { ContactRaw } from '../../models/contact.model';
|
||||||
import { MessageRaw, MessageUpdateRaw } from '../../models/message.model';
|
import { MessageRaw, MessageUpdateRaw } from '../../models/message.model';
|
||||||
|
import { ProviderFiles } from '../../provider/sessions';
|
||||||
import { RepositoryBroker } from '../../repository/repository.manager';
|
import { RepositoryBroker } from '../../repository/repository.manager';
|
||||||
import { waMonitor } from '../../server.module';
|
import { waMonitor } from '../../server.module';
|
||||||
import { Events, MessageSubtype, TypeMediaMessage, wa } from '../../types/wa.types';
|
import { Events, MessageSubtype, TypeMediaMessage, wa } from '../../types/wa.types';
|
||||||
import { CacheService } from './../cache.service';
|
import { CacheService } from './../cache.service';
|
||||||
import { ChannelStartupService } from './../channel.service';
|
import { ChannelStartupService } from './../channel.service';
|
||||||
|
|
||||||
|
const groupMetadataCache = new CacheService(new CacheEngine(configService, 'groups').getEngine());
|
||||||
|
|
||||||
export class BaileysStartupService extends ChannelStartupService {
|
export class BaileysStartupService extends ChannelStartupService {
|
||||||
constructor(
|
constructor(
|
||||||
public readonly configService: ConfigService,
|
public readonly configService: ConfigService,
|
||||||
@@ -127,7 +142,8 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
public readonly repository: RepositoryBroker,
|
public readonly repository: RepositoryBroker,
|
||||||
public readonly cache: CacheService,
|
public readonly cache: CacheService,
|
||||||
public readonly chatwootCache: CacheService,
|
public readonly chatwootCache: CacheService,
|
||||||
public readonly messagesLostCache: CacheService,
|
public readonly baileysCache: CacheService,
|
||||||
|
private readonly providerFiles: ProviderFiles,
|
||||||
) {
|
) {
|
||||||
super(configService, eventEmitter, repository, chatwootCache);
|
super(configService, eventEmitter, repository, chatwootCache);
|
||||||
this.logger.verbose('BaileysStartupService initialized');
|
this.logger.verbose('BaileysStartupService initialized');
|
||||||
@@ -135,8 +151,12 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
this.instance.qrcode = { count: 0 };
|
this.instance.qrcode = { count: 0 };
|
||||||
this.mobile = false;
|
this.mobile = false;
|
||||||
this.recoveringMessages();
|
this.recoveringMessages();
|
||||||
|
this.forceUpdateGroupMetadataCache();
|
||||||
|
|
||||||
|
this.authStateProvider = new AuthStateProvider(this.providerFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private authStateProvider: AuthStateProvider;
|
||||||
private readonly msgRetryCounterCache: CacheStore = new NodeCache();
|
private readonly msgRetryCounterCache: CacheStore = new NodeCache();
|
||||||
private readonly userDevicesCache: CacheStore = new NodeCache();
|
private readonly userDevicesCache: CacheStore = new NodeCache();
|
||||||
private endSession = false;
|
private endSession = false;
|
||||||
@@ -153,9 +173,9 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
|
|
||||||
if ((cacheConf?.REDIS?.ENABLED && cacheConf?.REDIS?.URI !== '') || cacheConf?.LOCAL?.ENABLED) {
|
if ((cacheConf?.REDIS?.ENABLED && cacheConf?.REDIS?.URI !== '') || cacheConf?.LOCAL?.ENABLED) {
|
||||||
setInterval(async () => {
|
setInterval(async () => {
|
||||||
this.messagesLostCache.keys().then((keys) => {
|
this.baileysCache.keys().then((keys) => {
|
||||||
keys.forEach(async (key) => {
|
keys.forEach(async (key) => {
|
||||||
const message = await this.messagesLostCache.get(key.split(':')[2]);
|
const message = await this.baileysCache.get(key.split(':')[2]);
|
||||||
|
|
||||||
if (message.messageStubParameters && message.messageStubParameters[0] === 'Message absent from node') {
|
if (message.messageStubParameters && message.messageStubParameters[0] === 'Message absent from node') {
|
||||||
this.logger.info('Message absent from node, retrying to send, key: ' + key.split(':')[2]);
|
this.logger.info('Message absent from node, retrying to send, key: ' + key.split(':')[2]);
|
||||||
@@ -167,6 +187,23 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async forceUpdateGroupMetadataCache() {
|
||||||
|
if (
|
||||||
|
!this.configService.get<CacheConf>('CACHE').REDIS.ENABLED &&
|
||||||
|
!this.configService.get<CacheConf>('CACHE').LOCAL.ENABLED
|
||||||
|
)
|
||||||
|
return;
|
||||||
|
|
||||||
|
setInterval(async () => {
|
||||||
|
this.logger.verbose('Forcing update group metadata cache');
|
||||||
|
const groups = await this.fetchAllGroups({ getParticipants: 'false' });
|
||||||
|
|
||||||
|
for (const group of groups) {
|
||||||
|
await this.updateGroupMetadataCache(group.id);
|
||||||
|
}
|
||||||
|
}, 3600000);
|
||||||
|
}
|
||||||
|
|
||||||
public get connectionStatus() {
|
public get connectionStatus() {
|
||||||
this.logger.verbose('Getting connection status');
|
this.logger.verbose('Getting connection status');
|
||||||
return this.stateConnection;
|
return this.stateConnection;
|
||||||
@@ -217,8 +254,8 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
this.logger.verbose('Getting profile status');
|
this.logger.verbose('Getting profile status');
|
||||||
const status = await this.client.fetchStatus(this.instance.wuid);
|
const status = await this.client.fetchStatus(this.instance.wuid);
|
||||||
|
|
||||||
this.logger.verbose(`Profile status: ${status.status}`);
|
this.logger.verbose(`Profile status: ${status[0]?.status}`);
|
||||||
return status.status;
|
return status[0]?.status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public get profilePictureUrl() {
|
public get profilePictureUrl() {
|
||||||
@@ -461,6 +498,12 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
const db = this.configService.get<Database>('DATABASE');
|
const db = this.configService.get<Database>('DATABASE');
|
||||||
const cache = this.configService.get<CacheConf>('CACHE');
|
const cache = this.configService.get<CacheConf>('CACHE');
|
||||||
|
|
||||||
|
const provider = this.configService.get<ProviderSession>('PROVIDER');
|
||||||
|
|
||||||
|
if (provider?.ENABLED) {
|
||||||
|
return await this.authStateProvider.authStateProvider(this.instance.name);
|
||||||
|
}
|
||||||
|
|
||||||
if (cache?.REDIS.ENABLED && cache?.REDIS.SAVE_INSTANCES) {
|
if (cache?.REDIS.ENABLED && cache?.REDIS.SAVE_INSTANCES) {
|
||||||
this.logger.info('Redis enabled');
|
this.logger.info('Redis enabled');
|
||||||
return await useMultiFileAuthStateRedisDb(this.instance.name, this.cache);
|
return await useMultiFileAuthStateRedisDb(this.instance.name, this.cache);
|
||||||
@@ -475,6 +518,143 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
return await useMultiFileAuthState(join(INSTANCE_DIR, this.instance.name));
|
return await useMultiFileAuthState(join(INSTANCE_DIR, this.instance.name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async createClient(number?: string, mobile?: boolean): Promise<WASocket> {
|
||||||
|
this.instance.authState = await this.defineAuthState();
|
||||||
|
|
||||||
|
if (!mobile) {
|
||||||
|
this.mobile = false;
|
||||||
|
} else {
|
||||||
|
this.mobile = mobile;
|
||||||
|
}
|
||||||
|
|
||||||
|
const session = this.configService.get<ConfigSessionPhone>('CONFIG_SESSION_PHONE');
|
||||||
|
|
||||||
|
let browserOptions = {};
|
||||||
|
|
||||||
|
if (number || this.phoneNumber) {
|
||||||
|
this.phoneNumber = number;
|
||||||
|
|
||||||
|
this.logger.info(`Phone number: ${number}`);
|
||||||
|
} else {
|
||||||
|
const browser: WABrowserDescription = [session.CLIENT, session.NAME, release()];
|
||||||
|
browserOptions = { browser };
|
||||||
|
|
||||||
|
this.logger.info(`Browser: ${browser}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
let version;
|
||||||
|
let log;
|
||||||
|
|
||||||
|
if (session.VERSION) {
|
||||||
|
version = session.VERSION.split(',');
|
||||||
|
log = `Baileys version env: ${version}`;
|
||||||
|
} else {
|
||||||
|
const baileysVersion = await fetchLatestBaileysVersion();
|
||||||
|
version = baileysVersion.version;
|
||||||
|
log = `Baileys version: ${version}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.logger.info(log);
|
||||||
|
|
||||||
|
let options;
|
||||||
|
|
||||||
|
if (this.localProxy.enabled) {
|
||||||
|
this.logger.info('Proxy enabled: ' + this.localProxy.proxy?.host);
|
||||||
|
|
||||||
|
if (this.localProxy?.proxy?.host?.includes('proxyscrape')) {
|
||||||
|
try {
|
||||||
|
const response = await axios.get(this.localProxy.proxy?.host);
|
||||||
|
const text = response.data;
|
||||||
|
const proxyUrls = text.split('\r\n');
|
||||||
|
const rand = Math.floor(Math.random() * Math.floor(proxyUrls.length));
|
||||||
|
const proxyUrl = 'http://' + proxyUrls[rand];
|
||||||
|
options = {
|
||||||
|
agent: makeProxyAgent(proxyUrl),
|
||||||
|
fetchAgent: makeProxyAgent(proxyUrl),
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
this.localProxy.enabled = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
options = {
|
||||||
|
agent: makeProxyAgent(this.localProxy.proxy),
|
||||||
|
fetchAgent: makeProxyAgent(this.localProxy.proxy),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const socketConfig: UserFacingSocketConfig = {
|
||||||
|
...options,
|
||||||
|
auth: {
|
||||||
|
creds: this.instance.authState.state.creds,
|
||||||
|
keys: makeCacheableSignalKeyStore(this.instance.authState.state.keys, P({ level: 'error' }) as any),
|
||||||
|
},
|
||||||
|
logger: P({ level: this.logBaileys }),
|
||||||
|
printQRInTerminal: false,
|
||||||
|
mobile,
|
||||||
|
...browserOptions,
|
||||||
|
version,
|
||||||
|
markOnlineOnConnect: this.localSettings.always_online,
|
||||||
|
retryRequestDelayMs: 350,
|
||||||
|
maxMsgRetryCount: 4,
|
||||||
|
fireInitQueries: true,
|
||||||
|
connectTimeoutMs: 20_000,
|
||||||
|
keepAliveIntervalMs: 30_000,
|
||||||
|
qrTimeout: 45_000,
|
||||||
|
defaultQueryTimeoutMs: undefined,
|
||||||
|
emitOwnEvents: false,
|
||||||
|
shouldIgnoreJid: (jid) => {
|
||||||
|
const isGroupJid = this.localSettings.groups_ignore && isJidGroup(jid);
|
||||||
|
const isBroadcast = !this.localSettings.read_status && isJidBroadcast(jid);
|
||||||
|
const isNewsletter = isJidNewsletter(jid);
|
||||||
|
|
||||||
|
return isGroupJid || isBroadcast || isNewsletter;
|
||||||
|
},
|
||||||
|
msgRetryCounterCache: this.msgRetryCounterCache,
|
||||||
|
getMessage: async (key) => (await this.getMessage(key)) as Promise<proto.IMessage>,
|
||||||
|
generateHighQualityLinkPreview: true,
|
||||||
|
syncFullHistory: this.localSettings.sync_full_history,
|
||||||
|
shouldSyncHistoryMessage: (msg: proto.Message.IHistorySyncNotification) => {
|
||||||
|
return this.historySyncNotification(msg);
|
||||||
|
},
|
||||||
|
userDevicesCache: this.userDevicesCache,
|
||||||
|
transactionOpts: { maxCommitRetries: 5, delayBetweenTriesMs: 2500 },
|
||||||
|
patchMessageBeforeSending(message) {
|
||||||
|
if (
|
||||||
|
message.deviceSentMessage?.message?.listMessage?.listType === proto.Message.ListMessage.ListType.PRODUCT_LIST
|
||||||
|
) {
|
||||||
|
message = JSON.parse(JSON.stringify(message));
|
||||||
|
|
||||||
|
message.deviceSentMessage.message.listMessage.listType = proto.Message.ListMessage.ListType.SINGLE_SELECT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (message.listMessage?.listType == proto.Message.ListMessage.ListType.PRODUCT_LIST) {
|
||||||
|
message = JSON.parse(JSON.stringify(message));
|
||||||
|
|
||||||
|
message.listMessage.listType = proto.Message.ListMessage.ListType.SINGLE_SELECT;
|
||||||
|
}
|
||||||
|
|
||||||
|
return message;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
this.endSession = false;
|
||||||
|
|
||||||
|
this.logger.verbose('Creating socket');
|
||||||
|
|
||||||
|
this.client = makeWASocket(socketConfig);
|
||||||
|
|
||||||
|
this.logger.verbose('Socket created');
|
||||||
|
|
||||||
|
this.eventHandler();
|
||||||
|
|
||||||
|
this.logger.verbose('Socket event handler initialized');
|
||||||
|
|
||||||
|
this.phoneNumber = number;
|
||||||
|
|
||||||
|
return this.client;
|
||||||
|
}
|
||||||
|
|
||||||
public async connectToWhatsapp(number?: string, mobile?: boolean): Promise<WASocket> {
|
public async connectToWhatsapp(number?: string, mobile?: boolean): Promise<WASocket> {
|
||||||
this.logger.verbose('Connecting to whatsapp');
|
this.logger.verbose('Connecting to whatsapp');
|
||||||
try {
|
try {
|
||||||
@@ -488,126 +668,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
this.loadProxy();
|
this.loadProxy();
|
||||||
this.loadChamaai();
|
this.loadChamaai();
|
||||||
|
|
||||||
this.instance.authState = await this.defineAuthState();
|
return await this.createClient(number, mobile);
|
||||||
|
|
||||||
if (!mobile) {
|
|
||||||
this.mobile = false;
|
|
||||||
} else {
|
|
||||||
this.mobile = mobile;
|
|
||||||
}
|
|
||||||
|
|
||||||
const session = this.configService.get<ConfigSessionPhone>('CONFIG_SESSION_PHONE');
|
|
||||||
const browser: WABrowserDescription = [session.CLIENT, session.NAME, release()];
|
|
||||||
this.logger.verbose('Browser: ' + JSON.stringify(browser));
|
|
||||||
|
|
||||||
let version;
|
|
||||||
let log;
|
|
||||||
|
|
||||||
if (session.VERSION) {
|
|
||||||
version = session.VERSION.split(',');
|
|
||||||
log = `Baileys version env: ${version}`;
|
|
||||||
} else {
|
|
||||||
const baileysVersion = await fetchLatestBaileysVersion();
|
|
||||||
version = baileysVersion.version;
|
|
||||||
log = `Baileys version: ${version}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.logger.info(log);
|
|
||||||
|
|
||||||
let options;
|
|
||||||
|
|
||||||
if (this.localProxy.enabled) {
|
|
||||||
this.logger.info('Proxy enabled: ' + this.localProxy.proxy?.host);
|
|
||||||
|
|
||||||
if (this.localProxy?.proxy?.host?.includes('proxyscrape')) {
|
|
||||||
try {
|
|
||||||
const response = await axios.get(this.localProxy.proxy?.host);
|
|
||||||
const text = response.data;
|
|
||||||
const proxyUrls = text.split('\r\n');
|
|
||||||
const rand = Math.floor(Math.random() * Math.floor(proxyUrls.length));
|
|
||||||
const proxyUrl = 'http://' + proxyUrls[rand];
|
|
||||||
options = {
|
|
||||||
agent: makeProxyAgent(proxyUrl),
|
|
||||||
fetchAgent: makeProxyAgent(proxyUrl),
|
|
||||||
};
|
|
||||||
} catch (error) {
|
|
||||||
this.localProxy.enabled = false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
options = {
|
|
||||||
agent: makeProxyAgent(this.localProxy.proxy),
|
|
||||||
fetchAgent: makeProxyAgent(this.localProxy.proxy),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const socketConfig: UserFacingSocketConfig = {
|
|
||||||
...options,
|
|
||||||
auth: {
|
|
||||||
creds: this.instance.authState.state.creds,
|
|
||||||
keys: makeCacheableSignalKeyStore(this.instance.authState.state.keys, P({ level: 'error' }) as any),
|
|
||||||
},
|
|
||||||
logger: P({ level: this.logBaileys }),
|
|
||||||
printQRInTerminal: false,
|
|
||||||
mobile,
|
|
||||||
browser: number ? ['Chrome (Linux)', session.NAME, release()] : browser,
|
|
||||||
version,
|
|
||||||
markOnlineOnConnect: this.localSettings.always_online,
|
|
||||||
retryRequestDelayMs: 10,
|
|
||||||
connectTimeoutMs: 60_000,
|
|
||||||
qrTimeout: 40_000,
|
|
||||||
defaultQueryTimeoutMs: undefined,
|
|
||||||
emitOwnEvents: false,
|
|
||||||
shouldIgnoreJid: (jid) => {
|
|
||||||
const isGroupJid = this.localSettings.groups_ignore && isJidGroup(jid);
|
|
||||||
const isBroadcast = !this.localSettings.read_status && isJidBroadcast(jid);
|
|
||||||
|
|
||||||
return isGroupJid || isBroadcast;
|
|
||||||
},
|
|
||||||
msgRetryCounterCache: this.msgRetryCounterCache,
|
|
||||||
getMessage: async (key) => (await this.getMessage(key)) as Promise<proto.IMessage>,
|
|
||||||
generateHighQualityLinkPreview: true,
|
|
||||||
syncFullHistory: this.localSettings.sync_full_history,
|
|
||||||
shouldSyncHistoryMessage: (msg: proto.Message.IHistorySyncNotification) => {
|
|
||||||
return this.historySyncNotification(msg);
|
|
||||||
},
|
|
||||||
userDevicesCache: this.userDevicesCache,
|
|
||||||
transactionOpts: { maxCommitRetries: 10, delayBetweenTriesMs: 10 },
|
|
||||||
patchMessageBeforeSending(message) {
|
|
||||||
if (
|
|
||||||
message.deviceSentMessage?.message?.listMessage?.listType ===
|
|
||||||
proto.Message.ListMessage.ListType.PRODUCT_LIST
|
|
||||||
) {
|
|
||||||
message = JSON.parse(JSON.stringify(message));
|
|
||||||
|
|
||||||
message.deviceSentMessage.message.listMessage.listType = proto.Message.ListMessage.ListType.SINGLE_SELECT;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (message.listMessage?.listType == proto.Message.ListMessage.ListType.PRODUCT_LIST) {
|
|
||||||
message = JSON.parse(JSON.stringify(message));
|
|
||||||
|
|
||||||
message.listMessage.listType = proto.Message.ListMessage.ListType.SINGLE_SELECT;
|
|
||||||
}
|
|
||||||
|
|
||||||
return message;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
this.endSession = false;
|
|
||||||
|
|
||||||
this.logger.verbose('Creating socket');
|
|
||||||
|
|
||||||
this.client = makeWASocket(socketConfig);
|
|
||||||
|
|
||||||
this.logger.verbose('Socket created');
|
|
||||||
|
|
||||||
this.eventHandler();
|
|
||||||
|
|
||||||
this.logger.verbose('Socket event handler initialized');
|
|
||||||
|
|
||||||
this.phoneNumber = number;
|
|
||||||
|
|
||||||
return this.client;
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logger.error(error);
|
this.logger.error(error);
|
||||||
throw new InternalServerErrorException(error?.toString());
|
throw new InternalServerErrorException(error?.toString());
|
||||||
@@ -628,12 +689,8 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('phoneNumber', phoneNumber);
|
|
||||||
|
|
||||||
const parsedPhoneNumber = parsePhoneNumber(phoneNumber);
|
const parsedPhoneNumber = parsePhoneNumber(phoneNumber);
|
||||||
|
|
||||||
console.log('parsedPhoneNumber', parsedPhoneNumber);
|
|
||||||
|
|
||||||
if (!parsedPhoneNumber?.isValid()) {
|
if (!parsedPhoneNumber?.isValid()) {
|
||||||
this.logger.error('Phone number invalid');
|
this.logger.error('Phone number invalid');
|
||||||
return;
|
return;
|
||||||
@@ -655,7 +712,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
try {
|
try {
|
||||||
const response = await this.client.requestRegistrationCode(registration);
|
const response = await this.client.requestRegistrationCode(registration);
|
||||||
|
|
||||||
console.log('response', response);
|
|
||||||
if (['ok', 'sent'].includes(response?.status)) {
|
if (['ok', 'sent'].includes(response?.status)) {
|
||||||
this.logger.verbose('Registration code sent successfully');
|
this.logger.verbose('Registration code sent successfully');
|
||||||
|
|
||||||
@@ -669,9 +725,8 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
public async receiveMobileCode(code: string) {
|
public async receiveMobileCode(code: string) {
|
||||||
await this.client
|
await this.client
|
||||||
.register(code.replace(/["']/g, '').trim().toLowerCase())
|
.register(code.replace(/["']/g, '').trim().toLowerCase())
|
||||||
.then(async (response) => {
|
.then(async () => {
|
||||||
this.logger.verbose('Registration code received successfully');
|
this.logger.verbose('Registration code received successfully');
|
||||||
console.log(response);
|
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.logger.error(error);
|
this.logger.error(error);
|
||||||
@@ -680,106 +735,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
|
|
||||||
public async reloadConnection(): Promise<WASocket> {
|
public async reloadConnection(): Promise<WASocket> {
|
||||||
try {
|
try {
|
||||||
this.instance.authState = await this.defineAuthState();
|
return await this.createClient(this.phoneNumber, this.mobile);
|
||||||
|
|
||||||
const session = this.configService.get<ConfigSessionPhone>('CONFIG_SESSION_PHONE');
|
|
||||||
const browser: WABrowserDescription = [session.CLIENT, session.NAME, release()];
|
|
||||||
|
|
||||||
let version;
|
|
||||||
let log;
|
|
||||||
|
|
||||||
if (session.VERSION) {
|
|
||||||
version = session.VERSION.split(',');
|
|
||||||
log = `Baileys version env: ${version}`;
|
|
||||||
} else {
|
|
||||||
const baileysVersion = await fetchLatestBaileysVersion();
|
|
||||||
version = baileysVersion.version;
|
|
||||||
log = `Baileys version: ${version}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.logger.info(log);
|
|
||||||
|
|
||||||
let options;
|
|
||||||
|
|
||||||
if (this.localProxy.enabled) {
|
|
||||||
this.logger.info('Proxy enabled: ' + this.localProxy.proxy?.host);
|
|
||||||
|
|
||||||
if (this.localProxy?.proxy?.host?.includes('proxyscrape')) {
|
|
||||||
try {
|
|
||||||
const response = await axios.get(this.localProxy.proxy?.host);
|
|
||||||
const text = response.data;
|
|
||||||
const proxyUrls = text.split('\r\n');
|
|
||||||
const rand = Math.floor(Math.random() * Math.floor(proxyUrls.length));
|
|
||||||
const proxyUrl = 'http://' + proxyUrls[rand];
|
|
||||||
options = {
|
|
||||||
agent: makeProxyAgent(proxyUrl),
|
|
||||||
fetchAgent: makeProxyAgent(proxyUrl),
|
|
||||||
};
|
|
||||||
} catch (error) {
|
|
||||||
this.localProxy.enabled = false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
options = {
|
|
||||||
agent: makeProxyAgent(this.localProxy.proxy),
|
|
||||||
fetchAgent: makeProxyAgent(this.localProxy.proxy),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const socketConfig: UserFacingSocketConfig = {
|
|
||||||
...options,
|
|
||||||
auth: {
|
|
||||||
creds: this.instance.authState.state.creds,
|
|
||||||
keys: makeCacheableSignalKeyStore(this.instance.authState.state.keys, P({ level: 'error' }) as any),
|
|
||||||
},
|
|
||||||
logger: P({ level: this.logBaileys }),
|
|
||||||
printQRInTerminal: false,
|
|
||||||
browser: this.phoneNumber ? ['Chrome (Linux)', session.NAME, release()] : browser,
|
|
||||||
version,
|
|
||||||
markOnlineOnConnect: this.localSettings.always_online,
|
|
||||||
retryRequestDelayMs: 10,
|
|
||||||
connectTimeoutMs: 60_000,
|
|
||||||
qrTimeout: 40_000,
|
|
||||||
defaultQueryTimeoutMs: undefined,
|
|
||||||
emitOwnEvents: false,
|
|
||||||
shouldIgnoreJid: (jid) => {
|
|
||||||
const isGroupJid = this.localSettings.groups_ignore && isJidGroup(jid);
|
|
||||||
const isBroadcast = !this.localSettings.read_status && isJidBroadcast(jid);
|
|
||||||
|
|
||||||
return isGroupJid || isBroadcast;
|
|
||||||
},
|
|
||||||
msgRetryCounterCache: this.msgRetryCounterCache,
|
|
||||||
getMessage: async (key) => (await this.getMessage(key)) as Promise<proto.IMessage>,
|
|
||||||
generateHighQualityLinkPreview: true,
|
|
||||||
syncFullHistory: this.localSettings.sync_full_history,
|
|
||||||
shouldSyncHistoryMessage: (msg: proto.Message.IHistorySyncNotification) => {
|
|
||||||
return this.historySyncNotification(msg);
|
|
||||||
},
|
|
||||||
userDevicesCache: this.userDevicesCache,
|
|
||||||
transactionOpts: { maxCommitRetries: 10, delayBetweenTriesMs: 10 },
|
|
||||||
patchMessageBeforeSending(message) {
|
|
||||||
if (
|
|
||||||
message.deviceSentMessage?.message?.listMessage?.listType ===
|
|
||||||
proto.Message.ListMessage.ListType.PRODUCT_LIST
|
|
||||||
) {
|
|
||||||
message = JSON.parse(JSON.stringify(message));
|
|
||||||
|
|
||||||
message.deviceSentMessage.message.listMessage.listType = proto.Message.ListMessage.ListType.SINGLE_SELECT;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (message.listMessage?.listType == proto.Message.ListMessage.ListType.PRODUCT_LIST) {
|
|
||||||
message = JSON.parse(JSON.stringify(message));
|
|
||||||
|
|
||||||
message.listMessage.listType = proto.Message.ListMessage.ListType.SINGLE_SELECT;
|
|
||||||
}
|
|
||||||
|
|
||||||
return message;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
this.client = makeWASocket(socketConfig);
|
|
||||||
|
|
||||||
return this.client;
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logger.error(error);
|
this.logger.error(error);
|
||||||
throw new InternalServerErrorException(error?.toString());
|
throw new InternalServerErrorException(error?.toString());
|
||||||
@@ -1017,7 +973,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
m.messageTimestamp = m.messageTimestamp?.toNumber();
|
m.messageTimestamp = m.messageTimestamp?.toNumber();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m.messageTimestamp <= timestampLimitToImport) {
|
if ((m.messageTimestamp as number) <= timestampLimitToImport) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1105,15 +1061,15 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
if (received.messageStubParameters && received.messageStubParameters[0] === 'Message absent from node') {
|
if (received.messageStubParameters && received.messageStubParameters[0] === 'Message absent from node') {
|
||||||
this.logger.info('Recovering message lost');
|
this.logger.info('Recovering message lost');
|
||||||
|
|
||||||
await this.messagesLostCache.set(received.key.id, received);
|
await this.baileysCache.set(received.key.id, received);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const retryCache = (await this.messagesLostCache.get(received.key.id)) || null;
|
const retryCache = (await this.baileysCache.get(received.key.id)) || null;
|
||||||
|
|
||||||
if (retryCache) {
|
if (retryCache) {
|
||||||
this.logger.info('Recovered message lost');
|
this.logger.info('Recovered message lost');
|
||||||
await this.messagesLostCache.delete(received.key.id);
|
await this.baileysCache.delete(received.key.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
@@ -1142,6 +1098,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
received?.message?.videoMessage ||
|
received?.message?.videoMessage ||
|
||||||
received?.message?.stickerMessage ||
|
received?.message?.stickerMessage ||
|
||||||
received?.message?.documentMessage ||
|
received?.message?.documentMessage ||
|
||||||
|
received?.message?.documentWithCaptionMessage ||
|
||||||
received?.message?.audioMessage;
|
received?.message?.audioMessage;
|
||||||
|
|
||||||
const contentMsg = received?.message[getContentType(received.message)] as any;
|
const contentMsg = received?.message[getContentType(received.message)] as any;
|
||||||
@@ -1402,6 +1359,12 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
|
|
||||||
this.logger.verbose('Sending data to webhook in event GROUPS_UPDATE');
|
this.logger.verbose('Sending data to webhook in event GROUPS_UPDATE');
|
||||||
this.sendDataWebhook(Events.GROUPS_UPDATE, groupMetadataUpdate);
|
this.sendDataWebhook(Events.GROUPS_UPDATE, groupMetadataUpdate);
|
||||||
|
|
||||||
|
groupMetadataUpdate.forEach((group) => {
|
||||||
|
if (isJidGroup(group.id)) {
|
||||||
|
this.updateGroupMetadataCache(group.id);
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
'group-participants.update': (participantsUpdate: {
|
'group-participants.update': (participantsUpdate: {
|
||||||
@@ -1459,7 +1422,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
this.logger.verbose('Sending data to webhook in event LABELS_ASSOCIATION');
|
this.logger.verbose('Sending data to webhook in event LABELS_ASSOCIATION');
|
||||||
|
|
||||||
// Atualiza labels nos chats
|
// Atualiza labels nos chats
|
||||||
if (database.SAVE_DATA.CHATS) {
|
if (database.ENABLED && database.SAVE_DATA.CHATS) {
|
||||||
const chats = await this.repository.chat.find({
|
const chats = await this.repository.chat.find({
|
||||||
where: {
|
where: {
|
||||||
owner: this.instance.name,
|
owner: this.instance.name,
|
||||||
@@ -1687,7 +1650,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
this.logger.verbose('Getting status');
|
this.logger.verbose('Getting status');
|
||||||
return {
|
return {
|
||||||
wuid: jid,
|
wuid: jid,
|
||||||
status: (await this.client.fetchStatus(jid))?.status,
|
status: (await this.client.fetchStatus(jid))[0]?.status,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logger.verbose('Status not found');
|
this.logger.verbose('Status not found');
|
||||||
@@ -1838,7 +1801,11 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
let mentions: string[];
|
let mentions: string[];
|
||||||
if (isJidGroup(sender)) {
|
if (isJidGroup(sender)) {
|
||||||
try {
|
try {
|
||||||
const group = await this.findGroup({ groupJid: sender }, 'inner');
|
let group;
|
||||||
|
|
||||||
|
const cache = this.configService.get<CacheConf>('CACHE');
|
||||||
|
if (!cache.REDIS.ENABLED && !cache.LOCAL.ENABLED) group = await this.findGroup({ groupJid: sender }, 'inner');
|
||||||
|
else group = await this.getGroupMetadataCache(sender);
|
||||||
|
|
||||||
if (!group) {
|
if (!group) {
|
||||||
throw new NotFoundException('Group not found');
|
throw new NotFoundException('Group not found');
|
||||||
@@ -1891,7 +1858,12 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
key: message['reactionMessage']['key'],
|
key: message['reactionMessage']['key'],
|
||||||
},
|
},
|
||||||
} as unknown as AnyMessageContent,
|
} as unknown as AnyMessageContent,
|
||||||
option as unknown as MiscMessageGenerationOptions,
|
{
|
||||||
|
...option,
|
||||||
|
useCachedGroupMetadata:
|
||||||
|
!!this.configService.get<CacheConf>('CACHE').REDIS.ENABLED &&
|
||||||
|
!!this.configService.get<CacheConf>('CACHE').LOCAL.ENABLED,
|
||||||
|
} as unknown as MiscMessageGenerationOptions,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1904,7 +1876,12 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
mentions,
|
mentions,
|
||||||
linkPreview: linkPreview,
|
linkPreview: linkPreview,
|
||||||
} as unknown as AnyMessageContent,
|
} as unknown as AnyMessageContent,
|
||||||
option as unknown as MiscMessageGenerationOptions,
|
{
|
||||||
|
...option,
|
||||||
|
useCachedGroupMetadata:
|
||||||
|
!!this.configService.get<CacheConf>('CACHE').REDIS.ENABLED &&
|
||||||
|
!!this.configService.get<CacheConf>('CACHE').LOCAL.ENABLED,
|
||||||
|
} as unknown as MiscMessageGenerationOptions,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1919,7 +1896,12 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
},
|
},
|
||||||
mentions,
|
mentions,
|
||||||
},
|
},
|
||||||
option as unknown as MiscMessageGenerationOptions,
|
{
|
||||||
|
...option,
|
||||||
|
useCachedGroupMetadata:
|
||||||
|
!!this.configService.get<CacheConf>('CACHE').REDIS.ENABLED &&
|
||||||
|
!!this.configService.get<CacheConf>('CACHE').LOCAL.ENABLED,
|
||||||
|
} as unknown as MiscMessageGenerationOptions,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1940,7 +1922,12 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
return await this.client.sendMessage(
|
return await this.client.sendMessage(
|
||||||
sender,
|
sender,
|
||||||
message as unknown as AnyMessageContent,
|
message as unknown as AnyMessageContent,
|
||||||
option as unknown as MiscMessageGenerationOptions,
|
{
|
||||||
|
...option,
|
||||||
|
useCachedGroupMetadata:
|
||||||
|
!!this.configService.get<CacheConf>('CACHE').REDIS.ENABLED &&
|
||||||
|
!!this.configService.get<CacheConf>('CACHE').LOCAL.ENABLED,
|
||||||
|
} as unknown as MiscMessageGenerationOptions,
|
||||||
);
|
);
|
||||||
})();
|
})();
|
||||||
|
|
||||||
@@ -1995,18 +1982,37 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
|
|
||||||
const sender = isWA.jid;
|
const sender = isWA.jid;
|
||||||
|
|
||||||
this.logger.verbose('Sending presence');
|
if (data?.options?.delay && data?.options?.delay > 20000) {
|
||||||
await this.client.presenceSubscribe(sender);
|
let remainingDelay = data?.options.delay;
|
||||||
this.logger.verbose('Subscribing to presence');
|
while (remainingDelay > 20000) {
|
||||||
|
await this.client.presenceSubscribe(sender);
|
||||||
|
|
||||||
await this.client.sendPresenceUpdate(data.options?.presence ?? 'composing', sender);
|
await this.client.sendPresenceUpdate((data?.options?.presence as WAPresence) ?? 'composing', sender);
|
||||||
this.logger.verbose('Sending presence update: ' + data.options?.presence ?? 'composing');
|
|
||||||
|
|
||||||
await delay(data.options.delay);
|
await delay(20000);
|
||||||
this.logger.verbose('Set delay: ' + data.options.delay);
|
|
||||||
|
|
||||||
await this.client.sendPresenceUpdate('paused', sender);
|
await this.client.sendPresenceUpdate('paused', sender);
|
||||||
this.logger.verbose('Sending presence update: paused');
|
|
||||||
|
remainingDelay -= 20000;
|
||||||
|
}
|
||||||
|
if (remainingDelay > 0) {
|
||||||
|
await this.client.presenceSubscribe(sender);
|
||||||
|
|
||||||
|
await this.client.sendPresenceUpdate((data?.options?.presence as WAPresence) ?? 'composing', sender);
|
||||||
|
|
||||||
|
await delay(remainingDelay);
|
||||||
|
|
||||||
|
await this.client.sendPresenceUpdate('paused', sender);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
await this.client.presenceSubscribe(sender);
|
||||||
|
|
||||||
|
await this.client.sendPresenceUpdate((data?.options?.presence as WAPresence) ?? 'composing', sender);
|
||||||
|
|
||||||
|
await delay(data?.options?.delay);
|
||||||
|
|
||||||
|
await this.client.sendPresenceUpdate('paused', sender);
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logger.error(error);
|
this.logger.error(error);
|
||||||
throw new BadRequestException(error.toString());
|
throw new BadRequestException(error.toString());
|
||||||
@@ -3126,6 +3132,38 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Group
|
// Group
|
||||||
|
private async updateGroupMetadataCache(groupJid: string) {
|
||||||
|
try {
|
||||||
|
const meta = await this.client.groupMetadata(groupJid);
|
||||||
|
await groupMetadataCache.set(groupJid, {
|
||||||
|
timestamp: Date.now(),
|
||||||
|
data: meta,
|
||||||
|
});
|
||||||
|
|
||||||
|
return meta;
|
||||||
|
} catch (error) {
|
||||||
|
this.logger.error(error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async getGroupMetadataCache(groupJid: string) {
|
||||||
|
if (!isJidGroup(groupJid)) return null;
|
||||||
|
|
||||||
|
if (await groupMetadataCache.has(groupJid)) {
|
||||||
|
console.log('Has cache for group: ' + groupJid);
|
||||||
|
const meta = await groupMetadataCache.get(groupJid);
|
||||||
|
|
||||||
|
if (Date.now() - meta.timestamp > 3600000) {
|
||||||
|
await this.updateGroupMetadataCache(groupJid);
|
||||||
|
}
|
||||||
|
|
||||||
|
return meta.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
return await this.updateGroupMetadataCache(groupJid);
|
||||||
|
}
|
||||||
|
|
||||||
public async createGroup(create: CreateGroupDto) {
|
public async createGroup(create: CreateGroupDto) {
|
||||||
this.logger.verbose('Creating group: ' + create.subject);
|
this.logger.verbose('Creating group: ' + create.subject);
|
||||||
try {
|
try {
|
||||||
@@ -3222,6 +3260,10 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async findGroup(id: GroupJid, reply: 'inner' | 'out' = 'out') {
|
public async findGroup(id: GroupJid, reply: 'inner' | 'out' = 'out') {
|
||||||
|
if (this.localSettings.groups_ignore === true) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.logger.verbose('Fetching group');
|
this.logger.verbose('Fetching group');
|
||||||
try {
|
try {
|
||||||
const group = await this.client.groupMetadata(id.groupJid);
|
const group = await this.client.groupMetadata(id.groupJid);
|
||||||
@@ -3252,6 +3294,10 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async fetchAllGroups(getParticipants: GetParticipant) {
|
public async fetchAllGroups(getParticipants: GetParticipant) {
|
||||||
|
if (this.localSettings.groups_ignore === true) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.logger.verbose('Fetching all groups');
|
this.logger.verbose('Fetching all groups');
|
||||||
try {
|
try {
|
||||||
const fetch = Object.values(await this.client.groupFetchAllParticipating());
|
const fetch = Object.values(await this.client.groupFetchAllParticipating());
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import {
|
|||||||
SendTextDto,
|
SendTextDto,
|
||||||
} from '../../dto/sendMessage.dto';
|
} from '../../dto/sendMessage.dto';
|
||||||
import { ContactRaw, MessageRaw, MessageUpdateRaw, SettingsRaw } from '../../models';
|
import { ContactRaw, MessageRaw, MessageUpdateRaw, SettingsRaw } from '../../models';
|
||||||
|
import { ProviderFiles } from '../../provider/sessions';
|
||||||
import { RepositoryBroker } from '../../repository/repository.manager';
|
import { RepositoryBroker } from '../../repository/repository.manager';
|
||||||
import { Events, wa } from '../../types/wa.types';
|
import { Events, wa } from '../../types/wa.types';
|
||||||
import { CacheService } from './../cache.service';
|
import { CacheService } from './../cache.service';
|
||||||
@@ -35,7 +36,8 @@ export class BusinessStartupService extends ChannelStartupService {
|
|||||||
public readonly repository: RepositoryBroker,
|
public readonly repository: RepositoryBroker,
|
||||||
public readonly cache: CacheService,
|
public readonly cache: CacheService,
|
||||||
public readonly chatwootCache: CacheService,
|
public readonly chatwootCache: CacheService,
|
||||||
public readonly messagesLostCache: CacheService,
|
public readonly baileysCache: CacheService,
|
||||||
|
private readonly providerFiles: ProviderFiles,
|
||||||
) {
|
) {
|
||||||
super(configService, eventEmitter, repository, chatwootCache);
|
super(configService, eventEmitter, repository, chatwootCache);
|
||||||
this.logger.verbose('BusinessStartupService initialized');
|
this.logger.verbose('BusinessStartupService initialized');
|
||||||
|
|||||||
@@ -5,7 +5,15 @@ import { Db } from 'mongodb';
|
|||||||
import { Collection } from 'mongoose';
|
import { Collection } from 'mongoose';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
|
|
||||||
import { Auth, CacheConf, ConfigService, Database, DelInstance, HttpServer } from '../../config/env.config';
|
import {
|
||||||
|
Auth,
|
||||||
|
CacheConf,
|
||||||
|
ConfigService,
|
||||||
|
Database,
|
||||||
|
DelInstance,
|
||||||
|
HttpServer,
|
||||||
|
ProviderSession,
|
||||||
|
} from '../../config/env.config';
|
||||||
import { Logger } from '../../config/logger.config';
|
import { Logger } from '../../config/logger.config';
|
||||||
import { INSTANCE_DIR, STORE_DIR } from '../../config/path.config';
|
import { INSTANCE_DIR, STORE_DIR } from '../../config/path.config';
|
||||||
import { NotFoundException } from '../../exceptions';
|
import { NotFoundException } from '../../exceptions';
|
||||||
@@ -22,6 +30,7 @@ import {
|
|||||||
WebhookModel,
|
WebhookModel,
|
||||||
WebsocketModel,
|
WebsocketModel,
|
||||||
} from '../models';
|
} from '../models';
|
||||||
|
import { ProviderFiles } from '../provider/sessions';
|
||||||
import { RepositoryBroker } from '../repository/repository.manager';
|
import { RepositoryBroker } from '../repository/repository.manager';
|
||||||
import { Integration } from '../types/wa.types';
|
import { Integration } from '../types/wa.types';
|
||||||
import { CacheService } from './cache.service';
|
import { CacheService } from './cache.service';
|
||||||
@@ -35,7 +44,8 @@ export class WAMonitoringService {
|
|||||||
private readonly repository: RepositoryBroker,
|
private readonly repository: RepositoryBroker,
|
||||||
private readonly cache: CacheService,
|
private readonly cache: CacheService,
|
||||||
private readonly chatwootCache: CacheService,
|
private readonly chatwootCache: CacheService,
|
||||||
private readonly messagesLostCache: CacheService,
|
private readonly baileysCache: CacheService,
|
||||||
|
private readonly providerFiles: ProviderFiles,
|
||||||
) {
|
) {
|
||||||
this.logger.verbose('instance created');
|
this.logger.verbose('instance created');
|
||||||
|
|
||||||
@@ -58,6 +68,8 @@ export class WAMonitoringService {
|
|||||||
private readonly logger = new Logger(WAMonitoringService.name);
|
private readonly logger = new Logger(WAMonitoringService.name);
|
||||||
public readonly waInstances: Record<string, BaileysStartupService | BusinessStartupService> = {};
|
public readonly waInstances: Record<string, BaileysStartupService | BusinessStartupService> = {};
|
||||||
|
|
||||||
|
private readonly providerSession = Object.freeze(this.configService.get<ProviderSession>('PROVIDER'));
|
||||||
|
|
||||||
public delInstanceTime(instance: string) {
|
public delInstanceTime(instance: string) {
|
||||||
const time = this.configService.get<DelInstance>('DEL_INSTANCE');
|
const time = this.configService.get<DelInstance>('DEL_INSTANCE');
|
||||||
if (typeof time === 'number' && time > 0) {
|
if (typeof time === 'number' && time > 0) {
|
||||||
@@ -83,7 +95,7 @@ export class WAMonitoringService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async instanceInfo(instanceName?: string) {
|
public async instanceInfo(instanceName?: string, arrayReturn = false) {
|
||||||
this.logger.verbose('get instance info');
|
this.logger.verbose('get instance info');
|
||||||
if (instanceName && !this.waInstances[instanceName]) {
|
if (instanceName && !this.waInstances[instanceName]) {
|
||||||
throw new NotFoundException(`Instance "${instanceName}" not found`);
|
throw new NotFoundException(`Instance "${instanceName}" not found`);
|
||||||
@@ -171,6 +183,9 @@ export class WAMonitoringService {
|
|||||||
|
|
||||||
this.logger.verbose('return instance info: ' + instances.length);
|
this.logger.verbose('return instance info: ' + instances.length);
|
||||||
|
|
||||||
|
if (arrayReturn) {
|
||||||
|
return [instances.find((i) => i.instance.instanceName === instanceName) ?? instances];
|
||||||
|
}
|
||||||
return instances.find((i) => i.instance.instanceName === instanceName) ?? instances;
|
return instances.find((i) => i.instance.instanceName === instanceName) ?? instances;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,12 +269,18 @@ export class WAMonitoringService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.logger.verbose('cleaning up instance in files: ' + instanceName);
|
this.logger.verbose('cleaning up instance in files: ' + instanceName);
|
||||||
|
if (this.providerSession?.ENABLED) {
|
||||||
|
await this.providerFiles.removeSession(instanceName);
|
||||||
|
}
|
||||||
rmSync(join(INSTANCE_DIR, instanceName), { recursive: true, force: true });
|
rmSync(join(INSTANCE_DIR, instanceName), { recursive: true, force: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
public async cleaningStoreFiles(instanceName: string) {
|
public async cleaningStoreFiles(instanceName: string) {
|
||||||
if (!this.db.ENABLED) {
|
if (!this.db.ENABLED) {
|
||||||
this.logger.verbose('cleaning store files instance: ' + instanceName);
|
this.logger.verbose('cleaning store files instance: ' + instanceName);
|
||||||
|
if (this.providerSession?.ENABLED) {
|
||||||
|
await this.providerFiles.removeSession(instanceName);
|
||||||
|
}
|
||||||
rmSync(join(INSTANCE_DIR, instanceName), { recursive: true, force: true });
|
rmSync(join(INSTANCE_DIR, instanceName), { recursive: true, force: true });
|
||||||
|
|
||||||
execSync(`rm -rf ${join(STORE_DIR, 'chats', instanceName)}`);
|
execSync(`rm -rf ${join(STORE_DIR, 'chats', instanceName)}`);
|
||||||
@@ -302,7 +323,9 @@ export class WAMonitoringService {
|
|||||||
this.logger.verbose('Loading instances');
|
this.logger.verbose('Loading instances');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (this.redis.REDIS.ENABLED && this.redis.REDIS.SAVE_INSTANCES) {
|
if (this.providerSession?.ENABLED) {
|
||||||
|
await this.loadInstancesFromProvider();
|
||||||
|
} else if (this.redis.REDIS.ENABLED && this.redis.REDIS.SAVE_INSTANCES) {
|
||||||
await this.loadInstancesFromRedis();
|
await this.loadInstancesFromRedis();
|
||||||
} else if (this.db.ENABLED && this.db.SAVE_DATA.INSTANCE) {
|
} else if (this.db.ENABLED && this.db.SAVE_DATA.INSTANCE) {
|
||||||
await this.loadInstancesFromDatabase();
|
await this.loadInstancesFromDatabase();
|
||||||
@@ -345,7 +368,8 @@ export class WAMonitoringService {
|
|||||||
this.repository,
|
this.repository,
|
||||||
this.cache,
|
this.cache,
|
||||||
this.chatwootCache,
|
this.chatwootCache,
|
||||||
this.messagesLostCache,
|
this.baileysCache,
|
||||||
|
this.providerFiles,
|
||||||
);
|
);
|
||||||
|
|
||||||
instance.instanceName = name;
|
instance.instanceName = name;
|
||||||
@@ -356,7 +380,8 @@ export class WAMonitoringService {
|
|||||||
this.repository,
|
this.repository,
|
||||||
this.cache,
|
this.cache,
|
||||||
this.chatwootCache,
|
this.chatwootCache,
|
||||||
this.messagesLostCache,
|
this.baileysCache,
|
||||||
|
this.providerFiles,
|
||||||
);
|
);
|
||||||
|
|
||||||
instance.instanceName = name;
|
instance.instanceName = name;
|
||||||
@@ -398,6 +423,18 @@ export class WAMonitoringService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async loadInstancesFromProvider() {
|
||||||
|
this.logger.verbose('Provider in files enabled');
|
||||||
|
const [instances] = await this.providerFiles.allInstances();
|
||||||
|
|
||||||
|
if (!instances?.data) {
|
||||||
|
this.logger.verbose('No instances found');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await Promise.all(instances?.data?.map(async (instanceName: string) => this.setInstance(instanceName)));
|
||||||
|
}
|
||||||
|
|
||||||
private async loadInstancesFromFiles() {
|
private async loadInstancesFromFiles() {
|
||||||
this.logger.verbose('Store in files enabled');
|
this.logger.verbose('Store in files enabled');
|
||||||
const dir = opendirSync(INSTANCE_DIR, { encoding: 'utf-8' });
|
const dir = opendirSync(INSTANCE_DIR, { encoding: 'utf-8' });
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-namespace */
|
/* eslint-disable @typescript-eslint/no-namespace */
|
||||||
import { AuthenticationState, WAConnectionState } from '@whiskeysockets/baileys';
|
import { AuthenticationState, WAConnectionState } from 'baileys';
|
||||||
|
|
||||||
export enum Events {
|
export enum Events {
|
||||||
APPLICATION_STARTUP = 'application.startup',
|
APPLICATION_STARTUP = 'application.startup',
|
||||||
@@ -69,6 +69,7 @@ export declare namespace wa {
|
|||||||
number?: string;
|
number?: string;
|
||||||
reopen_conversation?: boolean;
|
reopen_conversation?: boolean;
|
||||||
conversation_pending?: boolean;
|
conversation_pending?: boolean;
|
||||||
|
merge_brazil_contacts?: boolean;
|
||||||
import_contacts?: boolean;
|
import_contacts?: boolean;
|
||||||
import_messages?: boolean;
|
import_messages?: boolean;
|
||||||
days_limit_import_messages?: number;
|
days_limit_import_messages?: number;
|
||||||
|
|||||||
2
src/cache/rediscache.ts
vendored
2
src/cache/rediscache.ts
vendored
@@ -1,4 +1,4 @@
|
|||||||
import { BufferJSON } from '@whiskeysockets/baileys';
|
import { BufferJSON } from 'baileys';
|
||||||
import { RedisClientType } from 'redis';
|
import { RedisClientType } from 'redis';
|
||||||
|
|
||||||
import { ICache } from '../api/abstract/abstract.cache';
|
import { ICache } from '../api/abstract/abstract.cache';
|
||||||
|
|||||||
@@ -28,6 +28,13 @@ export type Log = {
|
|||||||
BAILEYS: LogBaileys;
|
BAILEYS: LogBaileys;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type ProviderSession = {
|
||||||
|
ENABLED: boolean;
|
||||||
|
HOST: string;
|
||||||
|
PORT: string;
|
||||||
|
PREFIX: string;
|
||||||
|
};
|
||||||
|
|
||||||
export type SaveData = {
|
export type SaveData = {
|
||||||
INSTANCE: boolean;
|
INSTANCE: boolean;
|
||||||
NEW_MESSAGE: boolean;
|
NEW_MESSAGE: boolean;
|
||||||
@@ -63,11 +70,42 @@ export type Database = {
|
|||||||
SAVE_DATA: SaveData;
|
SAVE_DATA: SaveData;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type EventsRabbitmq = {
|
||||||
|
APPLICATION_STARTUP: boolean;
|
||||||
|
INSTANCE_CREATE: boolean;
|
||||||
|
INSTANCE_DELETE: boolean;
|
||||||
|
QRCODE_UPDATED: boolean;
|
||||||
|
MESSAGES_SET: boolean;
|
||||||
|
MESSAGES_UPSERT: boolean;
|
||||||
|
MESSAGES_UPDATE: boolean;
|
||||||
|
MESSAGES_DELETE: boolean;
|
||||||
|
SEND_MESSAGE: boolean;
|
||||||
|
CONTACTS_SET: boolean;
|
||||||
|
CONTACTS_UPDATE: boolean;
|
||||||
|
CONTACTS_UPSERT: boolean;
|
||||||
|
PRESENCE_UPDATE: boolean;
|
||||||
|
CHATS_SET: boolean;
|
||||||
|
CHATS_UPDATE: boolean;
|
||||||
|
CHATS_DELETE: boolean;
|
||||||
|
CHATS_UPSERT: boolean;
|
||||||
|
CONNECTION_UPDATE: boolean;
|
||||||
|
LABELS_EDIT: boolean;
|
||||||
|
LABELS_ASSOCIATION: boolean;
|
||||||
|
GROUPS_UPSERT: boolean;
|
||||||
|
GROUP_UPDATE: boolean;
|
||||||
|
GROUP_PARTICIPANTS_UPDATE: boolean;
|
||||||
|
CALL: boolean;
|
||||||
|
NEW_JWT_TOKEN: boolean;
|
||||||
|
TYPEBOT_START: boolean;
|
||||||
|
TYPEBOT_CHANGE_STATUS: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
export type Rabbitmq = {
|
export type Rabbitmq = {
|
||||||
ENABLED: boolean;
|
ENABLED: boolean;
|
||||||
MODE: string; // global, single, isolated
|
|
||||||
EXCHANGE_NAME: string; // available for global and single, isolated mode will use instance name as exchange
|
|
||||||
URI: string;
|
URI: string;
|
||||||
|
EXCHANGE_NAME: string;
|
||||||
|
GLOBAL_ENABLED: boolean;
|
||||||
|
EVENTS: EventsRabbitmq;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Sqs = {
|
export type Sqs = {
|
||||||
@@ -178,6 +216,7 @@ export interface Env {
|
|||||||
SERVER: HttpServer;
|
SERVER: HttpServer;
|
||||||
CORS: Cors;
|
CORS: Cors;
|
||||||
SSL_CONF: SslConf;
|
SSL_CONF: SslConf;
|
||||||
|
PROVIDER: ProviderSession;
|
||||||
STORE: StoreConf;
|
STORE: StoreConf;
|
||||||
CLEAN_STORE: CleanStoreConf;
|
CLEAN_STORE: CleanStoreConf;
|
||||||
DATABASE: Database;
|
DATABASE: Database;
|
||||||
@@ -243,6 +282,12 @@ export class ConfigService {
|
|||||||
PRIVKEY: process.env?.SSL_CONF_PRIVKEY || '',
|
PRIVKEY: process.env?.SSL_CONF_PRIVKEY || '',
|
||||||
FULLCHAIN: process.env?.SSL_CONF_FULLCHAIN || '',
|
FULLCHAIN: process.env?.SSL_CONF_FULLCHAIN || '',
|
||||||
},
|
},
|
||||||
|
PROVIDER: {
|
||||||
|
ENABLED: process.env?.PROVIDER_ENABLED === 'true',
|
||||||
|
HOST: process.env.PROVIDER_HOST,
|
||||||
|
PORT: process.env?.PROVIDER_PORT || '5656',
|
||||||
|
PREFIX: process.env?.PROVIDER_PREFIX || 'evolution',
|
||||||
|
},
|
||||||
STORE: {
|
STORE: {
|
||||||
MESSAGES: process.env?.STORE_MESSAGES === 'true',
|
MESSAGES: process.env?.STORE_MESSAGES === 'true',
|
||||||
MESSAGE_UP: process.env?.STORE_MESSAGE_UP === 'true',
|
MESSAGE_UP: process.env?.STORE_MESSAGE_UP === 'true',
|
||||||
@@ -276,9 +321,38 @@ export class ConfigService {
|
|||||||
},
|
},
|
||||||
RABBITMQ: {
|
RABBITMQ: {
|
||||||
ENABLED: process.env?.RABBITMQ_ENABLED === 'true',
|
ENABLED: process.env?.RABBITMQ_ENABLED === 'true',
|
||||||
MODE: process.env?.RABBITMQ_MODE || 'isolated',
|
GLOBAL_ENABLED: process.env?.RABBITMQ_GLOBAL_ENABLED === 'true',
|
||||||
EXCHANGE_NAME: process.env?.RABBITMQ_EXCHANGE_NAME || 'evolution_exchange',
|
EXCHANGE_NAME: process.env?.RABBITMQ_EXCHANGE_NAME || 'evolution_exchange',
|
||||||
URI: process.env.RABBITMQ_URI || '',
|
URI: process.env.RABBITMQ_URI || '',
|
||||||
|
EVENTS: {
|
||||||
|
APPLICATION_STARTUP: process.env?.RABBITMQ_EVENTS_APPLICATION_STARTUP === 'true',
|
||||||
|
INSTANCE_CREATE: process.env?.RABBITMQ_EVENTS_INSTANCE_CREATE === 'true',
|
||||||
|
INSTANCE_DELETE: process.env?.RABBITMQ_EVENTS_INSTANCE_DELETE === 'true',
|
||||||
|
QRCODE_UPDATED: process.env?.RABBITMQ_EVENTS_QRCODE_UPDATED === 'true',
|
||||||
|
MESSAGES_SET: process.env?.RABBITMQ_EVENTS_MESSAGES_SET === 'true',
|
||||||
|
MESSAGES_UPSERT: process.env?.RABBITMQ_EVENTS_MESSAGES_UPSERT === 'true',
|
||||||
|
MESSAGES_UPDATE: process.env?.RABBITMQ_EVENTS_MESSAGES_UPDATE === 'true',
|
||||||
|
MESSAGES_DELETE: process.env?.RABBITMQ_EVENTS_MESSAGES_DELETE === 'true',
|
||||||
|
SEND_MESSAGE: process.env?.RABBITMQ_EVENTS_SEND_MESSAGE === 'true',
|
||||||
|
CONTACTS_SET: process.env?.RABBITMQ_EVENTS_CONTACTS_SET === 'true',
|
||||||
|
CONTACTS_UPDATE: process.env?.RABBITMQ_EVENTS_CONTACTS_UPDATE === 'true',
|
||||||
|
CONTACTS_UPSERT: process.env?.RABBITMQ_EVENTS_CONTACTS_UPSERT === 'true',
|
||||||
|
PRESENCE_UPDATE: process.env?.RABBITMQ_EVENTS_PRESENCE_UPDATE === 'true',
|
||||||
|
CHATS_SET: process.env?.RABBITMQ_EVENTS_CHATS_SET === 'true',
|
||||||
|
CHATS_UPDATE: process.env?.RABBITMQ_EVENTS_CHATS_UPDATE === 'true',
|
||||||
|
CHATS_UPSERT: process.env?.RABBITMQ_EVENTS_CHATS_UPSERT === 'true',
|
||||||
|
CHATS_DELETE: process.env?.RABBITMQ_EVENTS_CHATS_DELETE === 'true',
|
||||||
|
CONNECTION_UPDATE: process.env?.RABBITMQ_EVENTS_CONNECTION_UPDATE === 'true',
|
||||||
|
LABELS_EDIT: process.env?.RABBITMQ_EVENTS_LABELS_EDIT === 'true',
|
||||||
|
LABELS_ASSOCIATION: process.env?.RABBITMQ_EVENTS_LABELS_ASSOCIATION === 'true',
|
||||||
|
GROUPS_UPSERT: process.env?.RABBITMQ_EVENTS_GROUPS_UPSERT === 'true',
|
||||||
|
GROUP_UPDATE: process.env?.RABBITMQ_EVENTS_GROUPS_UPDATE === 'true',
|
||||||
|
GROUP_PARTICIPANTS_UPDATE: process.env?.RABBITMQ_EVENTS_GROUP_PARTICIPANTS_UPDATE === 'true',
|
||||||
|
CALL: process.env?.RABBITMQ_EVENTS_CALL === 'true',
|
||||||
|
NEW_JWT_TOKEN: process.env?.RABBITMQ_EVENTS_NEW_JWT_TOKEN === 'true',
|
||||||
|
TYPEBOT_START: process.env?.RABBITMQ_EVENTS_TYPEBOT_START === 'true',
|
||||||
|
TYPEBOT_CHANGE_STATUS: process.env?.RABBITMQ_EVENTS_TYPEBOT_CHANGE_STATUS === 'true',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
SQS: {
|
SQS: {
|
||||||
ENABLED: process.env?.SQS_ENABLED === 'true',
|
ENABLED: process.env?.SQS_ENABLED === 'true',
|
||||||
@@ -292,9 +366,9 @@ export class ConfigService {
|
|||||||
GLOBAL_EVENTS: process.env?.WEBSOCKET_GLOBAL_EVENTS === 'true',
|
GLOBAL_EVENTS: process.env?.WEBSOCKET_GLOBAL_EVENTS === 'true',
|
||||||
},
|
},
|
||||||
WA_BUSINESS: {
|
WA_BUSINESS: {
|
||||||
TOKEN_WEBHOOK: process.env.WA_BUSINESS_TOKEN_WEBHOOK || '',
|
TOKEN_WEBHOOK: process.env.WA_BUSINESS_TOKEN_WEBHOOK || 'evolution',
|
||||||
URL: process.env.WA_BUSINESS_URL || '',
|
URL: process.env.WA_BUSINESS_URL || 'https://graph.facebook.com',
|
||||||
VERSION: process.env.WA_BUSINESS_VERSION || '',
|
VERSION: process.env.WA_BUSINESS_VERSION || 'v19.0',
|
||||||
LANGUAGE: process.env.WA_BUSINESS_LANGUAGE || 'en',
|
LANGUAGE: process.env.WA_BUSINESS_LANGUAGE || 'en',
|
||||||
},
|
},
|
||||||
LOG: {
|
LOG: {
|
||||||
|
|||||||
@@ -49,6 +49,14 @@ LOG:
|
|||||||
DEL_INSTANCE: false # or false
|
DEL_INSTANCE: false # or false
|
||||||
DEL_TEMP_INSTANCES: true # Delete instances with status closed on start
|
DEL_TEMP_INSTANCES: true # Delete instances with status closed on start
|
||||||
|
|
||||||
|
# Seesion Files Providers
|
||||||
|
# Provider responsible for managing credentials files and WhatsApp sessions.
|
||||||
|
PROVIDER:
|
||||||
|
ENABLED: true
|
||||||
|
HOST: 127.0.0.1
|
||||||
|
PORT: 5656
|
||||||
|
PREFIX: evolution
|
||||||
|
|
||||||
# Temporary data storage
|
# Temporary data storage
|
||||||
STORE:
|
STORE:
|
||||||
MESSAGES: true
|
MESSAGES: true
|
||||||
@@ -79,9 +87,35 @@ DATABASE:
|
|||||||
|
|
||||||
RABBITMQ:
|
RABBITMQ:
|
||||||
ENABLED: false
|
ENABLED: false
|
||||||
MODE: "global"
|
|
||||||
EXCHANGE_NAME: "evolution_exchange"
|
|
||||||
URI: "amqp://guest:guest@localhost:5672"
|
URI: "amqp://guest:guest@localhost:5672"
|
||||||
|
EXCHANGE_NAME: evolution_exchange
|
||||||
|
GLOBAL_ENABLED: true
|
||||||
|
EVENTS:
|
||||||
|
APPLICATION_STARTUP: false
|
||||||
|
INSTANCE_CREATE: false
|
||||||
|
INSTANCE_DELETE: false
|
||||||
|
QRCODE_UPDATED: false
|
||||||
|
MESSAGES_SET: false
|
||||||
|
MESSAGES_UPSERT: true
|
||||||
|
MESSAGES_UPDATE: true
|
||||||
|
MESSAGES_DELETE: false
|
||||||
|
SEND_MESSAGE: false
|
||||||
|
CONTACTS_SET: false
|
||||||
|
CONTACTS_UPSERT: false
|
||||||
|
CONTACTS_UPDATE: false
|
||||||
|
PRESENCE_UPDATE: false
|
||||||
|
CHATS_SET: false
|
||||||
|
CHATS_UPSERT: false
|
||||||
|
CHATS_UPDATE: false
|
||||||
|
CHATS_DELETE: false
|
||||||
|
GROUPS_UPSERT: true
|
||||||
|
GROUP_UPDATE: true
|
||||||
|
GROUP_PARTICIPANTS_UPDATE: true
|
||||||
|
CONNECTION_UPDATE: true
|
||||||
|
CALL: false
|
||||||
|
# This events is used with Typebot
|
||||||
|
TYPEBOT_START: false
|
||||||
|
TYPEBOT_CHANGE_STATUS: false
|
||||||
|
|
||||||
SQS:
|
SQS:
|
||||||
ENABLED: true
|
ENABLED: true
|
||||||
@@ -168,7 +202,7 @@ CHATWOOT:
|
|||||||
# This db connection is used to import messages from whatsapp to chatwoot database
|
# This db connection is used to import messages from whatsapp to chatwoot database
|
||||||
DATABASE:
|
DATABASE:
|
||||||
CONNECTION:
|
CONNECTION:
|
||||||
URI: "postgres://user:password@hostname:port/dbname"
|
URI: "postgres://user:password@hostname:port/dbname?sslmode=disable"
|
||||||
PLACEHOLDER_MEDIA_MESSAGE: true
|
PLACEHOLDER_MEDIA_MESSAGE: true
|
||||||
|
|
||||||
# Cache to optimize application performance
|
# Cache to optimize application performance
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ info:
|
|||||||
</font>
|
</font>
|
||||||
|
|
||||||
[](https://god.gw.postman.com/run-collection/26869335-5546d063-156b-4529-915f-909dd628c090?action=collection%2Ffork&source=rip_markdown&collection-url=entityId%3D26869335-5546d063-156b-4529-915f-909dd628c090%26entityType%3Dcollection%26workspaceId%3D339a4ee7-378b-45c9-b5b8-fd2c0a9c2442)
|
[](https://god.gw.postman.com/run-collection/26869335-5546d063-156b-4529-915f-909dd628c090?action=collection%2Ffork&source=rip_markdown&collection-url=entityId%3D26869335-5546d063-156b-4529-915f-909dd628c090%26entityType%3Dcollection%26workspaceId%3D339a4ee7-378b-45c9-b5b8-fd2c0a9c2442)
|
||||||
version: 1.7.5
|
version: 1.8.2
|
||||||
contact:
|
contact:
|
||||||
name: DavidsonGomes
|
name: DavidsonGomes
|
||||||
email: contato@agenciadgcode.com
|
email: contato@agenciadgcode.com
|
||||||
|
|||||||
21
src/main.ts
21
src/main.ts
@@ -6,12 +6,13 @@ import cors from 'cors';
|
|||||||
import express, { json, NextFunction, Request, Response, urlencoded } from 'express';
|
import express, { json, NextFunction, Request, Response, urlencoded } from 'express';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
|
|
||||||
import { initAMQP } from './api/integrations/rabbitmq/libs/amqp.server';
|
import { initAMQP, initGlobalQueues } from './api/integrations/rabbitmq/libs/amqp.server';
|
||||||
import { initSQS } from './api/integrations/sqs/libs/sqs.server';
|
import { initSQS } from './api/integrations/sqs/libs/sqs.server';
|
||||||
import { initIO } from './api/integrations/websocket/libs/socket.server';
|
import { initIO } from './api/integrations/websocket/libs/socket.server';
|
||||||
|
import { ProviderFiles } from './api/provider/sessions';
|
||||||
import { HttpStatus, router } from './api/routes/index.router';
|
import { HttpStatus, router } from './api/routes/index.router';
|
||||||
import { waMonitor } from './api/server.module';
|
import { waMonitor } from './api/server.module';
|
||||||
import { Auth, configService, Cors, HttpServer, Rabbitmq, Sqs, Webhook } from './config/env.config';
|
import { Auth, configService, Cors, HttpServer, ProviderSession, Rabbitmq, Sqs, Webhook } from './config/env.config';
|
||||||
import { onUnexpectedError } from './config/error.config';
|
import { onUnexpectedError } from './config/error.config';
|
||||||
import { Logger } from './config/logger.config';
|
import { Logger } from './config/logger.config';
|
||||||
import { ROOT_DIR } from './config/path.config';
|
import { ROOT_DIR } from './config/path.config';
|
||||||
@@ -22,10 +23,18 @@ function initWA() {
|
|||||||
waMonitor.loadInstance();
|
waMonitor.loadInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
function bootstrap() {
|
async function bootstrap() {
|
||||||
const logger = new Logger('SERVER');
|
const logger = new Logger('SERVER');
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
|
let providerFiles: ProviderFiles = null;
|
||||||
|
|
||||||
|
if (configService.get<ProviderSession>('PROVIDER')?.ENABLED) {
|
||||||
|
providerFiles = new ProviderFiles(configService);
|
||||||
|
await providerFiles.onModuleInit();
|
||||||
|
logger.info('Provider:Files - ON');
|
||||||
|
}
|
||||||
|
|
||||||
app.use(
|
app.use(
|
||||||
cors({
|
cors({
|
||||||
origin(requestOrigin, callback) {
|
origin(requestOrigin, callback) {
|
||||||
@@ -128,7 +137,11 @@ function bootstrap() {
|
|||||||
|
|
||||||
initIO(server);
|
initIO(server);
|
||||||
|
|
||||||
if (configService.get<Rabbitmq>('RABBITMQ')?.ENABLED) initAMQP();
|
if (configService.get<Rabbitmq>('RABBITMQ')?.ENABLED) {
|
||||||
|
initAMQP().then(() => {
|
||||||
|
if (configService.get<Rabbitmq>('RABBITMQ')?.GLOBAL_ENABLED) initGlobalQueues();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (configService.get<Sqs>('SQS')?.ENABLED) initSQS();
|
if (configService.get<Sqs>('SQS')?.ENABLED) initSQS();
|
||||||
|
|
||||||
|
|||||||
@@ -1,29 +1,55 @@
|
|||||||
import {
|
import { AuthenticationState, BufferJSON, initAuthCreds, WAProto as proto } from 'baileys';
|
||||||
AuthenticationCreds,
|
import fs from 'fs/promises';
|
||||||
AuthenticationState,
|
import path from 'path';
|
||||||
BufferJSON,
|
|
||||||
initAuthCreds,
|
|
||||||
proto,
|
|
||||||
SignalDataTypeMap,
|
|
||||||
} from '@whiskeysockets/baileys';
|
|
||||||
|
|
||||||
import { configService, Database } from '../config/env.config';
|
import { configService, Database } from '../config/env.config';
|
||||||
import { Logger } from '../config/logger.config';
|
import { Logger } from '../config/logger.config';
|
||||||
|
import { INSTANCE_DIR } from '../config/path.config';
|
||||||
import { dbserver } from '../libs/db.connect';
|
import { dbserver } from '../libs/db.connect';
|
||||||
|
|
||||||
|
const fixFileName = (file) => {
|
||||||
|
if (!file) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
const replacedSlash = file.replace(/\//g, '__');
|
||||||
|
const replacedColon = replacedSlash.replace(/:/g, '-');
|
||||||
|
return replacedColon;
|
||||||
|
};
|
||||||
|
|
||||||
|
async function fileExists(file) {
|
||||||
|
try {
|
||||||
|
const stat = await fs.stat(file);
|
||||||
|
if (stat.isFile()) return true;
|
||||||
|
} catch (error) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export async function useMultiFileAuthStateDb(
|
export async function useMultiFileAuthStateDb(
|
||||||
coll: string,
|
coll: string,
|
||||||
): Promise<{ state: AuthenticationState; saveCreds: () => Promise<void> }> {
|
): Promise<{ state: AuthenticationState; saveCreds: () => Promise<void> }> {
|
||||||
const logger = new Logger(useMultiFileAuthStateDb.name);
|
|
||||||
|
|
||||||
const client = dbserver.getClient();
|
const client = dbserver.getClient();
|
||||||
|
|
||||||
|
const logger = new Logger(useMultiFileAuthStateDb.name);
|
||||||
|
|
||||||
const collection = client
|
const collection = client
|
||||||
.db(configService.get<Database>('DATABASE').CONNECTION.DB_PREFIX_NAME + '-instances')
|
.db(configService.get<Database>('DATABASE').CONNECTION.DB_PREFIX_NAME + '-instances')
|
||||||
.collection(coll);
|
.collection(coll);
|
||||||
|
|
||||||
const writeData = async (data: any, key: string): Promise<any> => {
|
const sessionId = coll;
|
||||||
|
|
||||||
|
const localFolder = path.join(INSTANCE_DIR, sessionId);
|
||||||
|
const localFile = (key: string) => path.join(localFolder, fixFileName(key) + '.json');
|
||||||
|
await fs.mkdir(localFolder, { recursive: true });
|
||||||
|
|
||||||
|
async function writeData(data: any, key: string): Promise<any> {
|
||||||
try {
|
try {
|
||||||
|
const dataString = JSON.stringify(data, BufferJSON.replacer);
|
||||||
|
|
||||||
|
if (key != 'creds') {
|
||||||
|
await fs.writeFile(localFile(key), dataString);
|
||||||
|
return;
|
||||||
|
}
|
||||||
await client.connect();
|
await client.connect();
|
||||||
let msgParsed = JSON.parse(JSON.stringify(data, BufferJSON.replacer));
|
let msgParsed = JSON.parse(JSON.stringify(data, BufferJSON.replacer));
|
||||||
if (Array.isArray(msgParsed)) {
|
if (Array.isArray(msgParsed)) {
|
||||||
@@ -37,42 +63,59 @@ export async function useMultiFileAuthStateDb(
|
|||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(error);
|
logger.error(error);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
const readData = async (key: string): Promise<any> => {
|
async function readData(key: string): Promise<any> {
|
||||||
try {
|
try {
|
||||||
await client.connect();
|
if (key != 'creds') {
|
||||||
let data = (await collection.findOne({ _id: key })) as any;
|
if (!(await fileExists(localFile(key)))) return null;
|
||||||
if (data?.content_array) {
|
const rawData = await fs.readFile(localFile(key), { encoding: 'utf-8' });
|
||||||
data = data.content_array;
|
|
||||||
|
const parsedData = JSON.parse(rawData, BufferJSON.reviver);
|
||||||
|
return parsedData;
|
||||||
|
} else {
|
||||||
|
await client.connect();
|
||||||
|
let data = (await collection.findOne({ _id: key })) as any;
|
||||||
|
if (data?.content_array) {
|
||||||
|
data = data.content_array;
|
||||||
|
}
|
||||||
|
const creds = JSON.stringify(data);
|
||||||
|
return JSON.parse(creds, BufferJSON.reviver);
|
||||||
}
|
}
|
||||||
const creds = JSON.stringify(data);
|
|
||||||
return JSON.parse(creds, BufferJSON.reviver);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(error);
|
logger.error(error);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
const removeData = async (key: string) => {
|
async function removeData(key: string): Promise<any> {
|
||||||
try {
|
try {
|
||||||
await client.connect();
|
if (key != 'creds') {
|
||||||
return await collection.deleteOne({ _id: key });
|
await fs.unlink(localFile(key));
|
||||||
|
} else {
|
||||||
|
await client.connect();
|
||||||
|
return await collection.deleteOne({ _id: key });
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(error);
|
logger.error(error);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
const creds: AuthenticationCreds = (await readData('creds')) || initAuthCreds();
|
let creds = await readData('creds');
|
||||||
|
if (!creds) {
|
||||||
|
creds = initAuthCreds();
|
||||||
|
await writeData(creds, 'creds');
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
state: {
|
state: {
|
||||||
creds,
|
creds,
|
||||||
keys: {
|
keys: {
|
||||||
get: async (type, ids: string[]) => {
|
get: async (type, ids) => {
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
const data = {};
|
||||||
// @ts-ignore
|
|
||||||
const data: { [_: string]: SignalDataTypeMap[type] } = {};
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
ids.map(async (id) => {
|
ids.map(async (id) => {
|
||||||
let value = await readData(`${type}-${id}`);
|
let value = await readData(`${type}-${id}`);
|
||||||
@@ -83,25 +126,24 @@ export async function useMultiFileAuthStateDb(
|
|||||||
data[id] = value;
|
data[id] = value;
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
set: async (data: any) => {
|
set: async (data) => {
|
||||||
const tasks: Promise<void>[] = [];
|
const tasks = [];
|
||||||
for (const category in data) {
|
for (const category in data) {
|
||||||
for (const id in data[category]) {
|
for (const id in data[category]) {
|
||||||
const value = data[category][id];
|
const value = data[category][id];
|
||||||
const key = `${category}-${id}`;
|
const key = `${category}-${id}`;
|
||||||
|
|
||||||
tasks.push(value ? writeData(value, key) : removeData(key));
|
tasks.push(value ? writeData(value, key) : removeData(key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await Promise.all(tasks);
|
await Promise.all(tasks);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
saveCreds: async () => {
|
saveCreds: () => {
|
||||||
return await writeData(creds, 'creds');
|
return writeData(creds, 'creds');
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
132
src/utils/use-multi-file-auth-state-provider-files.ts
Normal file
132
src/utils/use-multi-file-auth-state-provider-files.ts
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
/**
|
||||||
|
* ┌──────────────────────────────────────────────────────────────────────────────┐
|
||||||
|
* │ @author jrCleber │
|
||||||
|
* │ @filename use-multi-file-auth-state-provider-files.ts │
|
||||||
|
* │ Developed by: Cleber Wilson │
|
||||||
|
* │ Creation date: May 31, 2024 │
|
||||||
|
* │ Contact: contato@codechat.dev │
|
||||||
|
* ├──────────────────────────────────────────────────────────────────────────────┤
|
||||||
|
* │ @copyright © Cleber Wilson 2023. All rights reserved. │
|
||||||
|
* │ Licensed under the Apache License, Version 2.0 │
|
||||||
|
* │ │
|
||||||
|
* │ @license "https://github.com/code-chat-br/whatsapp-api/blob/main/LICENSE" │
|
||||||
|
* │ │
|
||||||
|
* │ You may not use this file except in compliance with the License. │
|
||||||
|
* │ You may obtain a copy of the License at │
|
||||||
|
* │ │
|
||||||
|
* │ http://www.apache.org/licenses/LICENSE-2.0 │
|
||||||
|
* │ │
|
||||||
|
* │ Unless required by applicable law or agreed to in writing, software │
|
||||||
|
* │ distributed under the License is distributed on an "AS IS" BASIS, │
|
||||||
|
* │ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. │
|
||||||
|
* │ │
|
||||||
|
* │ See the License for the specific language governing permissions and │
|
||||||
|
* │ limitations under the License. │
|
||||||
|
* │ │
|
||||||
|
* │ @type {AuthState} │
|
||||||
|
* │ @function useMultiFileAuthStateRedisDb │
|
||||||
|
* │ @returns {Promise<AuthState>} │
|
||||||
|
* ├──────────────────────────────────────────────────────────────────────────────┤
|
||||||
|
* │ @important │
|
||||||
|
* │ For any future changes to the code in this file, it is recommended to │
|
||||||
|
* │ contain, together with the modification, the information of the developer │
|
||||||
|
* │ who changed it and the date of modification. │
|
||||||
|
* └──────────────────────────────────────────────────────────────────────────────┘
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { AuthenticationCreds, AuthenticationState, BufferJSON, initAuthCreds, proto, SignalDataTypeMap } from 'baileys';
|
||||||
|
import { isNotEmpty } from 'class-validator';
|
||||||
|
|
||||||
|
import { ProviderFiles } from '../api/provider/sessions';
|
||||||
|
import { Logger } from '../config/logger.config';
|
||||||
|
|
||||||
|
export type AuthState = { state: AuthenticationState; saveCreds: () => Promise<void> };
|
||||||
|
|
||||||
|
export class AuthStateProvider {
|
||||||
|
constructor(private readonly providerFiles: ProviderFiles) {}
|
||||||
|
|
||||||
|
private readonly logger = new Logger(AuthStateProvider.name);
|
||||||
|
|
||||||
|
public async authStateProvider(instance: string): Promise<AuthState> {
|
||||||
|
const [, error] = await this.providerFiles.create(instance);
|
||||||
|
if (error) {
|
||||||
|
this.logger.error(['Failed to create folder on file server', error?.message, error?.stack]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const writeData = async (data: any, key: string): Promise<any> => {
|
||||||
|
const json = JSON.stringify(data, BufferJSON.replacer);
|
||||||
|
const [response, error] = await this.providerFiles.write(instance, key, {
|
||||||
|
data: json,
|
||||||
|
});
|
||||||
|
if (error) {
|
||||||
|
// this.logger.error(['writeData', error?.message, error?.stack]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
};
|
||||||
|
|
||||||
|
const readData = async (key: string): Promise<any> => {
|
||||||
|
const [response, error] = await this.providerFiles.read(instance, key);
|
||||||
|
if (error) {
|
||||||
|
// this.logger.error(['readData', error?.message, error?.stack]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (isNotEmpty(response?.data)) {
|
||||||
|
return JSON.parse(JSON.stringify(response.data), BufferJSON.reviver);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const removeData = async (key: string) => {
|
||||||
|
const [response, error] = await this.providerFiles.delete(instance, key);
|
||||||
|
if (error) {
|
||||||
|
// this.logger.error(['removeData', error?.message, error?.stack]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return response;
|
||||||
|
};
|
||||||
|
|
||||||
|
const creds: AuthenticationCreds = (await readData('creds')) || initAuthCreds();
|
||||||
|
|
||||||
|
return {
|
||||||
|
state: {
|
||||||
|
creds,
|
||||||
|
keys: {
|
||||||
|
get: async (type, ids: string[]) => {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
|
// @ts-ignore
|
||||||
|
const data: { [_: string]: SignalDataTypeMap[type] } = {};
|
||||||
|
await Promise.all(
|
||||||
|
ids.map(async (id) => {
|
||||||
|
let value = await readData(`${type}-${id}`);
|
||||||
|
if (type === 'app-state-sync-key' && value) {
|
||||||
|
value = proto.Message.AppStateSyncKeyData.fromObject(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
data[id] = value;
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
return data;
|
||||||
|
},
|
||||||
|
set: async (data: any) => {
|
||||||
|
const tasks: Promise<void>[] = [];
|
||||||
|
for (const category in data) {
|
||||||
|
for (const id in data[category]) {
|
||||||
|
const value = data[category][id];
|
||||||
|
const key = `${category}-${id}`;
|
||||||
|
tasks.push(value ? await writeData(value, key) : await removeData(key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await Promise.all(tasks);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
saveCreds: async () => {
|
||||||
|
return await writeData(creds, 'creds');
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,10 +1,4 @@
|
|||||||
import {
|
import { AuthenticationCreds, AuthenticationState, initAuthCreds, proto, SignalDataTypeMap } from 'baileys';
|
||||||
AuthenticationCreds,
|
|
||||||
AuthenticationState,
|
|
||||||
initAuthCreds,
|
|
||||||
proto,
|
|
||||||
SignalDataTypeMap,
|
|
||||||
} from '@whiskeysockets/baileys';
|
|
||||||
|
|
||||||
import { CacheService } from '../api/services/cache.service';
|
import { CacheService } from '../api/services/cache.service';
|
||||||
import { Logger } from '../config/logger.config';
|
import { Logger } from '../config/logger.config';
|
||||||
|
|||||||
Reference in New Issue
Block a user