mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-12-19 11:52:20 -06:00
Compare commits
245 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5d91876974 | ||
|
|
5043ce8405 | ||
|
|
8e65526ce9 | ||
|
|
cae016f40a | ||
|
|
78150d0fc6 | ||
|
|
f95727edbf | ||
|
|
2d9ca15d74 | ||
|
|
cee6498ea0 | ||
|
|
86c603b3a1 | ||
|
|
960efcecd5 | ||
|
|
b36c37bf33 | ||
|
|
cc6adf0ee2 | ||
|
|
6990a2c9c0 | ||
|
|
b60215100e | ||
|
|
b6506dc661 | ||
|
|
03ee40388c | ||
|
|
6ddad8e85a | ||
|
|
555fa606ea | ||
|
|
ca474236b0 | ||
|
|
ebd70fe454 | ||
|
|
91f009a617 | ||
|
|
293f6a39c5 | ||
|
|
38bf859f43 | ||
|
|
1d81c79fe6 | ||
|
|
c55885b366 | ||
|
|
549ecd8801 | ||
|
|
5c6b70f372 | ||
|
|
418ca971fa | ||
|
|
3d6209618b | ||
|
|
05eb58be0e | ||
|
|
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 | ||
|
|
da06ed1185 | ||
|
|
67afbd6a77 | ||
|
|
8fce53b4af | ||
|
|
65bba23519 | ||
|
|
283b497788 | ||
|
|
8cc1b8daa8 | ||
|
|
9ccdb45a7a | ||
|
|
f78d360c38 | ||
|
|
6144fbe856 | ||
|
|
8446be7646 | ||
|
|
8875ab1e93 | ||
|
|
7c207a50e1 | ||
|
|
dcc32479ff | ||
|
|
09911c472d | ||
|
|
7a0149ee23 | ||
|
|
3ae8cf32b0 | ||
|
|
11cf947bbb | ||
|
|
60a20f61af | ||
|
|
e65c7b6bcf | ||
|
|
80c892aca3 | ||
|
|
39ee266598 | ||
|
|
aa58d7744e | ||
|
|
ea3b0b3712 | ||
|
|
d9d8707123 | ||
|
|
8e9a1e2ba5 | ||
|
|
e29b4865e8 | ||
|
|
4b60ca175d | ||
|
|
2fbbc7b5a9 | ||
|
|
633dbb82d3 | ||
|
|
95907b3cea | ||
|
|
14c210c771 | ||
|
|
00e7fcc46b | ||
|
|
720efcbcbf | ||
|
|
d95791cc18 | ||
|
|
d45b7af3b6 | ||
|
|
0ad3acaf07 | ||
|
|
e27818ecda | ||
|
|
ff21cf4d4c | ||
|
|
dc19c7fdec | ||
|
|
6c8ffd8ec6 | ||
|
|
96fdb210be | ||
|
|
84ad8e0d6e | ||
|
|
53361682f4 | ||
|
|
0ee243f284 | ||
|
|
26ff0b634f | ||
|
|
f44ab0f678 | ||
|
|
1f128747bb | ||
|
|
3bf975d90f | ||
|
|
92f8951be4 | ||
|
|
e071f56767 | ||
|
|
c85619efcf | ||
|
|
27f9ae1e56 | ||
|
|
7449102d95 | ||
|
|
234a2c71b5 | ||
|
|
4dd5533202 | ||
|
|
a4d1740754 | ||
|
|
1a2ea1c38a | ||
|
|
371ec9b8d5 | ||
|
|
5e288d57ea | ||
|
|
61bd5b3484 | ||
|
|
bb974e10f5 | ||
|
|
4ed1335f89 | ||
|
|
4274c7afdb | ||
|
|
27f67142c8 | ||
|
|
ac8aba6ba4 | ||
|
|
07ff61c070 | ||
|
|
3645ac6704 | ||
|
|
9764719245 | ||
|
|
b3aeed7fc1 | ||
|
|
5ae5d8546e | ||
|
|
d190d8b1af | ||
|
|
c45538684d | ||
|
|
575e7bf4c4 | ||
|
|
a4338d8472 | ||
|
|
7d542cf115 | ||
|
|
9c9a542bbe | ||
|
|
b6c56551bc | ||
|
|
1379228196 | ||
|
|
d6e19b9273 | ||
|
|
5e0e4051dc | ||
|
|
8caf3a0a7b | ||
|
|
96ae97664c | ||
|
|
901b121695 | ||
|
|
3e88c9f0c7 | ||
|
|
94f5c130bf | ||
|
|
eb04c3f113 | ||
|
|
8ece6fb998 | ||
|
|
794213b5c6 | ||
|
|
ef4a9ab66b | ||
|
|
86e978faad | ||
|
|
d5d8f2a318 | ||
|
|
4ca1fad335 | ||
|
|
0edf6bdcb1 | ||
|
|
c2839ddd56 | ||
|
|
28581f88b2 | ||
|
|
833c625d18 | ||
|
|
6e2a3a410a | ||
|
|
3e85af9589 | ||
|
|
589dec52a3 | ||
|
|
a5477509bd | ||
|
|
5d951a96b5 | ||
|
|
76552f6ae5 | ||
|
|
e153515847 | ||
|
|
3bc692d894 | ||
|
|
73360d66cd | ||
|
|
04575d8051 | ||
|
|
9aba51cb45 | ||
|
|
1172b6c871 | ||
|
|
240f01f378 | ||
|
|
5975117636 | ||
|
|
51b285f665 | ||
|
|
b3958d4735 | ||
|
|
128119d494 | ||
|
|
324dc01699 | ||
|
|
f11d468e31 | ||
|
|
aa5ed13752 | ||
|
|
10ce7da18d | ||
|
|
73bd55dfac | ||
|
|
db10f81d53 | ||
|
|
717aac4438 | ||
|
|
077a464481 | ||
|
|
9bf18592fc | ||
|
|
677e196c96 | ||
|
|
19e6896f0d | ||
|
|
ba537baab2 | ||
|
|
2b8b6b086b | ||
|
|
cf3ec2b601 | ||
|
|
35eaa7852c |
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
|
||||
70
.github/workflows/publish_docker_image.yml
vendored
70
.github/workflows/publish_docker_image.yml
vendored
@@ -2,63 +2,47 @@ name: Build Docker image
|
||||
|
||||
on:
|
||||
push:
|
||||
tags: ['v*']
|
||||
tags:
|
||||
- "*.*.*"
|
||||
|
||||
jobs:
|
||||
build-amd:
|
||||
build_deploy:
|
||||
name: Build and Deploy
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
steps:
|
||||
- name: Check out the repo
|
||||
uses: actions/checkout@v3
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Extract existing image metadata
|
||||
id: image-meta
|
||||
uses: docker/metadata-action@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
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Log in to Docker Hub
|
||||
uses: docker/login-action@v2
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Build and push AMD image
|
||||
uses: docker/build-push-action@v4
|
||||
- name: Build and push
|
||||
id: docker_build
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
labels: ${{ steps.image-meta.outputs.labels }}
|
||||
platforms: linux/amd64
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
|
||||
build-arm:
|
||||
runs-on: buildjet-4vcpu-ubuntu-2204-arm
|
||||
steps:
|
||||
- name: Check out the repo
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Extract existing image metadata
|
||||
id: image-meta
|
||||
uses: docker/metadata-action@v4
|
||||
with:
|
||||
images: atendai/evolution-api
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Log in to Docker Hub
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Build and push ARM image
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
labels: ${{ steps.image-meta.outputs.labels }}
|
||||
platforms: linux/arm64
|
||||
push: true
|
||||
- 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 }}
|
||||
137
CHANGELOG.md
137
CHANGELOG.md
@@ -1,3 +1,140 @@
|
||||
# 1.8.7
|
||||
|
||||
### Features
|
||||
|
||||
* Wavoip integration
|
||||
|
||||
# 1.8.6
|
||||
|
||||
### Features
|
||||
|
||||
* Adds method to fetch contacts with last message
|
||||
|
||||
### Fixed
|
||||
|
||||
* Retry and Reconnect system in rabbitmq integration
|
||||
|
||||
### Feature
|
||||
|
||||
* RabbitMQ optimization with parameterized settings via environment variables (MESSAGE_TTL, MAX_LENGTH and MAX_LENGTH_BYTES)
|
||||
* Non-persistent messages to reduce disk usage
|
||||
* Automatic cleanup of expired messages in queues
|
||||
|
||||
# 1.8.5 (2025-02-03 12:32)
|
||||
|
||||
### Fixed
|
||||
|
||||
* Update Baileys Version
|
||||
|
||||
# 1.8.4 (2025-01-31 10:00)
|
||||
|
||||
### Features
|
||||
|
||||
* Added prefix key to queue name in RabbitMQ
|
||||
|
||||
# 1.8.3 (2024-11-29 10:00)
|
||||
|
||||
### Fixed
|
||||
|
||||
* Fixed issue sending group messages when ignore groups enabled
|
||||
* Fixed groups_ignore in /instance/create and maintaining compatibility
|
||||
|
||||
# 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)
|
||||
|
||||
### Fixed
|
||||
|
||||
* Add merge_brazil_contacts function to solve nine digit in brazilian numbers
|
||||
* Optimize ChatwootService method for updating contact
|
||||
* Fix swagger auth
|
||||
* Update aws sdk v3
|
||||
* Fix getOpenConversationByContact and init queries error
|
||||
* Method to mark chat as unread
|
||||
* Added environment variable to manually select the WhatsApp web version for the baileys lib (optional)
|
||||
|
||||
# 1.7.4 (2024-04-28 09:46)
|
||||
|
||||
### Fixed
|
||||
|
||||
* Adjusts in proxy on fetchAgent
|
||||
* Recovering messages lost with redis cache
|
||||
* Log when init redis cache service
|
||||
* Recovering messages lost with redis cache
|
||||
* Chatwoot inbox name
|
||||
* Update Baileys version
|
||||
|
||||
# 1.7.3 (2024-04-18 12:07)
|
||||
|
||||
### Fixed
|
||||
|
||||
* Revert fix audio encoding
|
||||
* Recovering messages lost with redis cache
|
||||
* Adjusts in redis for save instances
|
||||
* Adjusts in proxy
|
||||
* Revert pull request #523
|
||||
* Added instance name on logs
|
||||
* Added support for Spanish
|
||||
* Fix error: invalid operator. The allowed operators for identifier are equal_to,not_equal_to in chatwoot
|
||||
|
||||
# 1.7.2 (2024-04-12 17:31)
|
||||
|
||||
### Feature
|
||||
|
||||
* Mobile connection via sms (test)
|
||||
|
||||
### Fixed
|
||||
|
||||
* Adjusts in redis
|
||||
* Send global event in websocket
|
||||
* Adjusts in proxy
|
||||
* Fix audio encoding
|
||||
* Fix conversation read on chatwoot version 3.7
|
||||
* Fix when receiving/sending messages from whatsapp desktop with ephemeral messages enabled
|
||||
* Changed returned sessions on typebot status change
|
||||
* Reorganization of files and folders
|
||||
|
||||
# 1.7.1 (2024-04-03 10:19)
|
||||
|
||||
### Fixed
|
||||
|
||||
* Correction when sending files with captions on Whatsapp Business
|
||||
* Correction in receiving messages with response on WhatsApp Business
|
||||
* Correction when sending a reaction to a message on WhatsApp Business
|
||||
* Correction of receiving reactions on WhatsApp business
|
||||
* Removed mandatory description of rows from sendList
|
||||
* Feature to collect message type in typebot
|
||||
|
||||
# 1.7.0 (2024-03-11 18:23)
|
||||
|
||||
### Feature
|
||||
|
||||
@@ -43,16 +43,37 @@ DATABASE_SAVE_MESSAGE_UPDATE=false
|
||||
DATABASE_SAVE_DATA_CONTACTS=false
|
||||
DATABASE_SAVE_DATA_CHATS=false
|
||||
|
||||
REDIS_ENABLED=false
|
||||
REDIS_URI=redis://redis:6379
|
||||
REDIS_PREFIX_KEY=evdocker
|
||||
|
||||
RABBITMQ_ENABLED=false
|
||||
RABBITMQ_RABBITMQ_MODE=global
|
||||
RABBITMQ_EXCHANGE_NAME=evolution_exchange
|
||||
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_GLOBAL_EVENTS=false
|
||||
|
||||
WA_BUSINESS_TOKEN_WEBHOOK=evolution
|
||||
WA_BUSINESS_URL=https://graph.facebook.com
|
||||
@@ -113,7 +134,7 @@ CONFIG_SESSION_PHONE_NAME=Chrome
|
||||
|
||||
# Set qrcode display limit
|
||||
QRCODE_LIMIT=30
|
||||
QRCODE_COLOR=#198754
|
||||
QRCODE_COLOR='#198754'
|
||||
|
||||
# old | latest
|
||||
TYPEBOT_API_VERSION=latest
|
||||
@@ -125,9 +146,17 @@ 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.
|
||||
CHATWOOT_MESSAGE_READ=false # false | true
|
||||
# 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
|
||||
|
||||
CACHE_REDIS_ENABLED=false
|
||||
CACHE_REDIS_URI=redis://redis:6379
|
||||
CACHE_REDIS_PREFIX_KEY=evolution
|
||||
CACHE_REDIS_TTL=604800
|
||||
CACHE_REDIS_SAVE_INSTANCES=false
|
||||
CACHE_LOCAL_ENABLED=false
|
||||
CACHE_LOCAL_TTL=604800
|
||||
|
||||
# Defines an authentication type for the api
|
||||
# We recommend using the apikey because it will allow you to use a custom token,
|
||||
# if you use jwt, a random token will be generated and may be expired and you will have to generate a new token
|
||||
|
||||
@@ -33,7 +33,10 @@ CLEAN_STORE_CHATS=true
|
||||
|
||||
# Permanent data storage
|
||||
DATABASE_ENABLED=true
|
||||
DATABASE_CONNECTION_URI=mongodb://root:root@mongodb:27017/?authSource=admin&readPreference=primary&ssl=false&directConnection=true
|
||||
DATABASE_CONNECTION_URI=mongodb://root:root@mongodb:27017/?authSource=admin &
|
||||
readPreference=primary &
|
||||
ssl=false &
|
||||
directConnection=true
|
||||
DATABASE_CONNECTION_DB_PREFIX_NAME=evolution
|
||||
|
||||
# Choose the data you want to save in the application's database or store
|
||||
@@ -43,10 +46,6 @@ DATABASE_SAVE_MESSAGE_UPDATE=false
|
||||
DATABASE_SAVE_DATA_CONTACTS=false
|
||||
DATABASE_SAVE_DATA_CHATS=false
|
||||
|
||||
REDIS_ENABLED=true
|
||||
REDIS_URI=redis://redis:6379
|
||||
REDIS_PREFIX_KEY=evolution
|
||||
|
||||
# Global Webhook Settings
|
||||
# Each instance's Webhook URL and events will be requested at the time it is created
|
||||
## Define a global webhook that will listen for enabled events from all instances
|
||||
@@ -87,6 +86,14 @@ CONFIG_SESSION_PHONE_NAME=chrome
|
||||
# Set qrcode display limit
|
||||
QRCODE_LIMIT=30
|
||||
|
||||
CACHE_REDIS_ENABLED=false
|
||||
CACHE_REDIS_URI=redis://redis:6379
|
||||
CACHE_REDIS_PREFIX_KEY=evolution
|
||||
CACHE_REDIS_TTL=604800
|
||||
CACHE_REDIS_SAVE_INSTANCES=false
|
||||
CACHE_LOCAL_ENABLED=false
|
||||
CACHE_LOCAL_TTL=604800
|
||||
|
||||
# Defines an authentication type for the api
|
||||
# We recommend using the apikey because it will allow you to use a custom token,
|
||||
# if you use jwt, a random token will be generated and may be expired and you will have to generate a new token
|
||||
|
||||
45
Dockerfile
45
Dockerfile
@@ -1,6 +1,6 @@
|
||||
FROM node:20.7.0-alpine AS builder
|
||||
|
||||
LABEL version="1.7.0" 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 contact="contato@agenciadgcode.com"
|
||||
|
||||
@@ -58,16 +58,39 @@ ENV DATABASE_SAVE_MESSAGE_UPDATE=false
|
||||
ENV DATABASE_SAVE_DATA_CONTACTS=false
|
||||
ENV DATABASE_SAVE_DATA_CHATS=false
|
||||
|
||||
ENV REDIS_ENABLED=false
|
||||
ENV REDIS_URI=redis://redis:6379
|
||||
ENV REDIS_PREFIX_KEY=evolution
|
||||
|
||||
ENV RABBITMQ_ENABLED=false
|
||||
ENV RABBITMQ_MODE=global
|
||||
ENV RABBITMQ_EXCHANGE_NAME=evolution_exchange
|
||||
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_GLOBAL_EVENTS=false
|
||||
|
||||
ENV WA_BUSINESS_TOKEN_WEBHOOK=evolution
|
||||
ENV WA_BUSINESS_URL=https://graph.facebook.com
|
||||
@@ -128,6 +151,14 @@ ENV QRCODE_COLOR=#198754
|
||||
|
||||
ENV TYPEBOT_API_VERSION=latest
|
||||
|
||||
ENV CACHE_REDIS_ENABLED=false
|
||||
ENV CACHE_REDIS_URI=redis://redis:6379
|
||||
ENV CACHE_REDIS_PREFIX_KEY=evolution
|
||||
ENV CACHE_REDIS_TTL=604800
|
||||
ENV CACHE_REDIS_SAVE_INSTANCES=false
|
||||
ENV CACHE_LOCAL_ENABLED=false
|
||||
ENV CACHE_LOCAL_TTL=604800
|
||||
|
||||
ENV AUTHENTICATION_TYPE=apikey
|
||||
|
||||
ENV AUTHENTICATION_API_KEY=B6D711FCDE4D4FD5936544120E713976
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "evolution-api",
|
||||
"version": "1.7.0",
|
||||
"version": "1.8.6",
|
||||
"description": "Rest api for communication with WhatsApp",
|
||||
"main": "./dist/src/main.js",
|
||||
"scripts": {
|
||||
@@ -42,14 +42,14 @@
|
||||
"homepage": "https://github.com/EvolutionAPI/evolution-api#readme",
|
||||
"dependencies": {
|
||||
"@adiwajshing/keyed-db": "^0.2.4",
|
||||
"@aws-sdk/client-sqs": "^3.569.0",
|
||||
"@ffmpeg-installer/ffmpeg": "^1.1.0",
|
||||
"@figuro/chatwoot-sdk": "^1.1.16",
|
||||
"@hapi/boom": "^10.0.1",
|
||||
"@sentry/node": "^7.59.2",
|
||||
"@whiskeysockets/baileys": "6.6.0",
|
||||
"amqplib": "^0.10.3",
|
||||
"aws-sdk": "^2.1499.0",
|
||||
"axios": "^1.6.5",
|
||||
"baileys": "github:EvolutionAPI/Baileys",
|
||||
"class-validator": "^0.14.1",
|
||||
"compression": "^1.7.4",
|
||||
"cors": "^2.8.5",
|
||||
@@ -60,6 +60,7 @@
|
||||
"exiftool-vendored": "^22.0.0",
|
||||
"express": "^4.18.2",
|
||||
"express-async-errors": "^3.1.1",
|
||||
"fluent-ffmpeg": "^2.1.2",
|
||||
"form-data": "^4.0.0",
|
||||
"hbs": "^4.2.0",
|
||||
"https-proxy-agent": "^7.0.2",
|
||||
@@ -83,6 +84,7 @@
|
||||
"redis": "^4.6.5",
|
||||
"sharp": "^0.32.2",
|
||||
"socket.io": "^4.7.1",
|
||||
"socket.io-client": "^4.8.1",
|
||||
"socks-proxy-agent": "^8.0.1",
|
||||
"swagger-ui-express": "^5.0.0",
|
||||
"uuid": "^9.0.0",
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
export interface ICache {
|
||||
get(key: string): Promise<any>;
|
||||
|
||||
hGet(key: string, field: string): Promise<any>;
|
||||
|
||||
set(key: string, value: any, ttl?: number): void;
|
||||
|
||||
hSet(key: string, field: string, value: any): Promise<void>;
|
||||
|
||||
has(key: string): Promise<boolean>;
|
||||
|
||||
keys(appendCriteria?: string): Promise<string[]>;
|
||||
|
||||
delete(key: string | string[]): Promise<number>;
|
||||
|
||||
hDelete(key: string, field: string): Promise<any>;
|
||||
|
||||
deleteAll(appendCriteria?: string): Promise<number>;
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
BlockUserDto,
|
||||
DeleteMessage,
|
||||
getBase64FromMediaMessageDto,
|
||||
MarkChatUnreadDto,
|
||||
NumberDto,
|
||||
PrivacySettingDto,
|
||||
ProfileNameDto,
|
||||
@@ -40,6 +41,11 @@ export class ChatController {
|
||||
return await this.waMonitor.waInstances[instanceName].archiveChat(data);
|
||||
}
|
||||
|
||||
public async markChatUnread({ instanceName }: InstanceDto, data: MarkChatUnreadDto) {
|
||||
logger.verbose('requested markChatUnread from ' + instanceName + ' instance');
|
||||
return await this.waMonitor.waInstances[instanceName].markChatUnread(data);
|
||||
}
|
||||
|
||||
public async deleteMessage({ instanceName }: InstanceDto, data: DeleteMessage) {
|
||||
logger.verbose('requested deleteMessage from ' + instanceName + ' instance');
|
||||
return await this.waMonitor.waInstances[instanceName].deleteMessage(data);
|
||||
@@ -80,6 +86,11 @@ export class ChatController {
|
||||
return await this.waMonitor.waInstances[instanceName].fetchChats();
|
||||
}
|
||||
|
||||
public async fetchContactsWithLastMessage({ instanceName }: InstanceDto) {
|
||||
logger.verbose('requested fetchContactsWithLastMessage from ' + instanceName + ' instance');
|
||||
return await this.waMonitor.waInstances[instanceName].fetchContactsWithLastMessage();
|
||||
}
|
||||
|
||||
public async sendPresence({ instanceName }: InstanceDto, data: SendPresenceDto) {
|
||||
logger.verbose('requested sendPresence from ' + instanceName + ' instance');
|
||||
return await this.waMonitor.waInstances[instanceName].sendPresence(data);
|
||||
@@ -1,28 +1,29 @@
|
||||
import { delay } from '@whiskeysockets/baileys';
|
||||
import { delay } from 'baileys';
|
||||
import { isURL } from 'class-validator';
|
||||
import EventEmitter2 from 'eventemitter2';
|
||||
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 { BadRequestException, InternalServerErrorException } from '../../exceptions';
|
||||
import { RedisCache } from '../../libs/redis.client';
|
||||
import { BadRequestException, InternalServerErrorException, UnauthorizedException } from '../../exceptions';
|
||||
import { InstanceDto, SetPresenceDto } from '../dto/instance.dto';
|
||||
import { ChatwootService } from '../integrations/chatwoot/services/chatwoot.service';
|
||||
import { RabbitmqService } from '../integrations/rabbitmq/services/rabbitmq.service';
|
||||
import { SqsService } from '../integrations/sqs/services/sqs.service';
|
||||
import { TypebotService } from '../integrations/typebot/services/typebot.service';
|
||||
import { WebsocketService } from '../integrations/websocket/services/websocket.service';
|
||||
import { ProviderFiles } from '../provider/sessions';
|
||||
import { RepositoryBroker } from '../repository/repository.manager';
|
||||
import { AuthService, OldToken } from '../services/auth.service';
|
||||
import { CacheService } from '../services/cache.service';
|
||||
import { ChatwootService } from '../services/chatwoot.service';
|
||||
import { BaileysStartupService } from '../services/channels/whatsapp.baileys.service';
|
||||
import { BusinessStartupService } from '../services/channels/whatsapp.business.service';
|
||||
import { IntegrationService } from '../services/integration.service';
|
||||
import { WAMonitoringService } from '../services/monitor.service';
|
||||
import { RabbitmqService } from '../services/rabbitmq.service';
|
||||
import { SettingsService } from '../services/settings.service';
|
||||
import { SqsService } from '../services/sqs.service';
|
||||
import { TypebotService } from '../services/typebot.service';
|
||||
import { WebhookService } from '../services/webhook.service';
|
||||
import { WebsocketService } from '../services/websocket.service';
|
||||
import { BaileysStartupService } from '../services/whatsapp.baileys.service';
|
||||
import { BusinessStartupService } from '../services/whatsapp.business.service';
|
||||
import { Events, Integration, wa } from '../types/wa.types';
|
||||
import { ProxyController } from './proxy.controller';
|
||||
|
||||
export class InstanceController {
|
||||
constructor(
|
||||
@@ -39,8 +40,11 @@ export class InstanceController {
|
||||
private readonly sqsService: SqsService,
|
||||
private readonly typebotService: TypebotService,
|
||||
private readonly integrationService: IntegrationService,
|
||||
private readonly cache: RedisCache,
|
||||
private readonly proxyService: ProxyController,
|
||||
private readonly cache: CacheService,
|
||||
private readonly chatwootCache: CacheService,
|
||||
private readonly baileysCache: CacheService,
|
||||
private readonly providerFiles: ProviderFiles,
|
||||
) {}
|
||||
|
||||
private readonly logger = new Logger(InstanceController.name);
|
||||
@@ -53,6 +57,7 @@ export class InstanceController {
|
||||
events,
|
||||
qrcode,
|
||||
number,
|
||||
mobile,
|
||||
integration,
|
||||
token,
|
||||
chatwoot_account_id,
|
||||
@@ -62,6 +67,8 @@ export class InstanceController {
|
||||
chatwoot_reopen_conversation,
|
||||
chatwoot_conversation_pending,
|
||||
chatwoot_import_contacts,
|
||||
chatwoot_name_inbox,
|
||||
chatwoot_merge_brazil_contacts,
|
||||
chatwoot_import_messages,
|
||||
chatwoot_days_limit_import_messages,
|
||||
reject_call,
|
||||
@@ -71,6 +78,7 @@ export class InstanceController {
|
||||
read_messages,
|
||||
read_status,
|
||||
sync_full_history,
|
||||
wavoipToken,
|
||||
websocket_enabled,
|
||||
websocket_events,
|
||||
rabbitmq_enabled,
|
||||
@@ -84,6 +92,7 @@ export class InstanceController {
|
||||
typebot_delay_message,
|
||||
typebot_unknown_message,
|
||||
typebot_listening_from_me,
|
||||
proxy,
|
||||
}: InstanceDto) {
|
||||
try {
|
||||
this.logger.verbose('requested createInstance from ' + instanceName + ' instance');
|
||||
@@ -104,6 +113,8 @@ export class InstanceController {
|
||||
this.repository,
|
||||
this.cache,
|
||||
this.chatwootCache,
|
||||
this.baileysCache,
|
||||
this.providerFiles,
|
||||
);
|
||||
} else {
|
||||
instance = new BaileysStartupService(
|
||||
@@ -112,10 +123,12 @@ export class InstanceController {
|
||||
this.repository,
|
||||
this.cache,
|
||||
this.chatwootCache,
|
||||
this.baileysCache,
|
||||
this.providerFiles,
|
||||
);
|
||||
}
|
||||
|
||||
await this.waMonitor.saveInstance({ integration, instanceName, token, number });
|
||||
await this.waMonitor.saveInstance({ integration, instanceName, token, number, mobile });
|
||||
|
||||
instance.instanceName = instanceName;
|
||||
|
||||
@@ -345,6 +358,18 @@ export class InstanceController {
|
||||
}
|
||||
}
|
||||
|
||||
if (proxy) {
|
||||
const testProxy = await this.proxyService.testProxy(proxy);
|
||||
if (!testProxy) {
|
||||
throw new BadRequestException('Invalid proxy');
|
||||
}
|
||||
|
||||
await this.proxyService.createProxy(instance, {
|
||||
enabled: true,
|
||||
proxy,
|
||||
});
|
||||
}
|
||||
|
||||
if (typebot_url) {
|
||||
try {
|
||||
if (!isURL(typebot_url, { require_tld: false })) {
|
||||
@@ -372,11 +397,12 @@ export class InstanceController {
|
||||
const settings: wa.LocalSettings = {
|
||||
reject_call: reject_call || false,
|
||||
msg_call: msg_call || '',
|
||||
groups_ignore: groups_ignore || true,
|
||||
groups_ignore: groups_ignore === undefined ? true : groups_ignore || false,
|
||||
always_online: always_online || false,
|
||||
read_messages: read_messages || false,
|
||||
read_status: read_status || false,
|
||||
sync_full_history: sync_full_history ?? false,
|
||||
wavoipToken: wavoipToken ?? '',
|
||||
};
|
||||
|
||||
this.logger.verbose('settings: ' + JSON.stringify(settings));
|
||||
@@ -405,7 +431,7 @@ export class InstanceController {
|
||||
|
||||
if (qrcode) {
|
||||
this.logger.verbose('creating qrcode');
|
||||
await instance.connectToWhatsapp(number);
|
||||
await instance.connectToWhatsapp(number, mobile);
|
||||
await delay(5000);
|
||||
getQrcode = instance.qrCode;
|
||||
}
|
||||
@@ -495,11 +521,12 @@ export class InstanceController {
|
||||
token: chatwoot_token,
|
||||
url: chatwoot_url,
|
||||
sign_msg: chatwoot_sign_msg || false,
|
||||
name_inbox: instance.instanceName.split('-cwId-')[0],
|
||||
name_inbox: chatwoot_name_inbox ?? instance.instanceName.split('-cwId-')[0],
|
||||
number,
|
||||
reopen_conversation: chatwoot_reopen_conversation || false,
|
||||
conversation_pending: chatwoot_conversation_pending || false,
|
||||
import_contacts: chatwoot_import_contacts ?? true,
|
||||
merge_brazil_contacts: chatwoot_merge_brazil_contacts ?? false,
|
||||
import_messages: chatwoot_import_messages ?? true,
|
||||
days_limit_import_messages: chatwoot_days_limit_import_messages ?? 60,
|
||||
auto_create: true,
|
||||
@@ -555,11 +582,12 @@ export class InstanceController {
|
||||
sign_msg: chatwoot_sign_msg || false,
|
||||
reopen_conversation: chatwoot_reopen_conversation || false,
|
||||
conversation_pending: chatwoot_conversation_pending || false,
|
||||
merge_brazil_contacts: chatwoot_merge_brazil_contacts ?? false,
|
||||
import_contacts: chatwoot_import_contacts ?? true,
|
||||
import_messages: chatwoot_import_messages ?? true,
|
||||
days_limit_import_messages: chatwoot_days_limit_import_messages || 60,
|
||||
number,
|
||||
name_inbox: instance.instanceName,
|
||||
name_inbox: chatwoot_name_inbox ?? instance.instanceName,
|
||||
webhook_url: `${urlServer}/chatwoot/webhook/${encodeURIComponent(instance.instanceName)}`,
|
||||
},
|
||||
};
|
||||
@@ -569,7 +597,7 @@ export class InstanceController {
|
||||
}
|
||||
}
|
||||
|
||||
public async connectToWhatsapp({ instanceName, number = null }: InstanceDto) {
|
||||
public async connectToWhatsapp({ instanceName, number = null, mobile = null }: InstanceDto) {
|
||||
try {
|
||||
this.logger.verbose('requested connectToWhatsapp from ' + instanceName + ' instance');
|
||||
|
||||
@@ -592,7 +620,7 @@ export class InstanceController {
|
||||
|
||||
if (state == 'close') {
|
||||
this.logger.verbose('connecting');
|
||||
await instance.connectToWhatsapp(number);
|
||||
await instance.connectToWhatsapp(number, mobile);
|
||||
|
||||
await delay(5000);
|
||||
return instance.qrCode;
|
||||
@@ -633,6 +661,20 @@ export class InstanceController {
|
||||
}
|
||||
}
|
||||
|
||||
public async registerMobileCode({ instanceName }: InstanceDto, { mobileCode }: any) {
|
||||
try {
|
||||
this.logger.verbose('requested registerMobileCode from ' + instanceName + ' instance');
|
||||
|
||||
const instance = this.waMonitor.waInstances[instanceName];
|
||||
|
||||
console.log('mobileCode', mobileCode);
|
||||
await instance.receiveMobileCode(mobileCode);
|
||||
return { status: 'SUCCESS', error: false, response: { message: 'Mobile code registered' } };
|
||||
} catch (error) {
|
||||
this.logger.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
public async connectionState({ instanceName }: InstanceDto) {
|
||||
this.logger.verbose('requested connectionState from ' + instanceName + ' instance');
|
||||
return {
|
||||
@@ -643,11 +685,26 @@ export class InstanceController {
|
||||
};
|
||||
}
|
||||
|
||||
public async fetchInstances({ instanceName, instanceId, number }: InstanceDto) {
|
||||
if (instanceName) {
|
||||
this.logger.verbose('requested fetchInstances from ' + instanceName + ' instance');
|
||||
this.logger.verbose('instanceName: ' + instanceName);
|
||||
return this.waMonitor.instanceInfo(instanceName);
|
||||
public async fetchInstances({ instanceName, instanceId, number }: InstanceDto, key: string) {
|
||||
const env = this.configService.get<Auth>('AUTHENTICATION').API_KEY;
|
||||
|
||||
let name = 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) {
|
||||
return this.waMonitor.instanceInfoById(instanceId, number);
|
||||
}
|
||||
@@ -682,23 +739,18 @@ export class InstanceController {
|
||||
this.logger.verbose('requested deleteInstance from ' + instanceName + ' instance');
|
||||
const { instance } = await this.connectionState({ instanceName });
|
||||
|
||||
if (instance.state === 'open') {
|
||||
throw new BadRequestException('The "' + instanceName + '" instance needs to be disconnected');
|
||||
}
|
||||
try {
|
||||
this.waMonitor.waInstances[instanceName]?.removeRabbitmqQueues();
|
||||
this.waMonitor.waInstances[instanceName]?.clearCacheChatwoot();
|
||||
|
||||
if (instance.state === 'connecting') {
|
||||
this.logger.verbose('logging out instance: ' + instanceName);
|
||||
|
||||
if (instance.state === 'connecting' || instance.state === 'open') {
|
||||
await this.logout({ instanceName });
|
||||
}
|
||||
|
||||
this.logger.verbose('deleting instance: ' + instanceName);
|
||||
|
||||
try {
|
||||
this.waMonitor.waInstances[instanceName].sendDataWebhook(Events.INSTANCE_DELETE, {
|
||||
this.waMonitor.waInstances[instanceName]?.sendDataWebhook(Events.INSTANCE_DELETE, {
|
||||
instanceName,
|
||||
instanceId: (await this.repository.auth.find(instanceName))?.instanceId,
|
||||
});
|
||||
@@ -46,7 +46,7 @@ export class ProxyController {
|
||||
return this.proxyService.find(instance);
|
||||
}
|
||||
|
||||
private async testProxy(proxy: ProxyDto['proxy']) {
|
||||
public async testProxy(proxy: ProxyDto['proxy']) {
|
||||
logger.verbose('requested testProxy');
|
||||
try {
|
||||
const serverIp = await axios.get('https://icanhazip.com/');
|
||||
@@ -1,4 +1,4 @@
|
||||
import { proto, WAPresence, WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue } from '@whiskeysockets/baileys';
|
||||
import { proto, WAPresence, WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue } from 'baileys';
|
||||
|
||||
export class OnWhatsAppDto {
|
||||
constructor(
|
||||
@@ -73,13 +73,18 @@ export class ArchiveChatDto {
|
||||
archive: boolean;
|
||||
}
|
||||
|
||||
export class MarkChatUnreadDto {
|
||||
lastMessage?: LastMessage;
|
||||
chat?: string;
|
||||
}
|
||||
|
||||
class PrivacySetting {
|
||||
readreceipts: WAReadReceiptsValue;
|
||||
profile: WAPrivacyValue;
|
||||
status: WAPrivacyValue;
|
||||
online: WAPrivacyOnlineValue;
|
||||
last: WAPrivacyValue;
|
||||
groupadd: WAPrivacyValue;
|
||||
groupadd: any;
|
||||
}
|
||||
|
||||
export class PrivacySettingDto {
|
||||
@@ -1,10 +1,13 @@
|
||||
import { WAPresence } from "@whiskeysockets/baileys";
|
||||
import { WAPresence } from 'baileys';
|
||||
|
||||
import { ProxyDto } from './proxy.dto';
|
||||
|
||||
export class InstanceDto {
|
||||
instanceName: string;
|
||||
instanceId?: string;
|
||||
qrcode?: boolean;
|
||||
number?: string;
|
||||
mobile?: boolean;
|
||||
integration?: string;
|
||||
token?: string;
|
||||
webhook?: string;
|
||||
@@ -18,15 +21,18 @@ export class InstanceDto {
|
||||
read_messages?: boolean;
|
||||
read_status?: boolean;
|
||||
sync_full_history?: boolean;
|
||||
wavoipToken?: string;
|
||||
chatwoot_account_id?: string;
|
||||
chatwoot_token?: string;
|
||||
chatwoot_url?: string;
|
||||
chatwoot_sign_msg?: boolean;
|
||||
chatwoot_reopen_conversation?: boolean;
|
||||
chatwoot_conversation_pending?: boolean;
|
||||
chatwoot_merge_brazil_contacts?: boolean;
|
||||
chatwoot_import_contacts?: boolean;
|
||||
chatwoot_import_messages?: boolean;
|
||||
chatwoot_days_limit_import_messages?: number;
|
||||
chatwoot_name_inbox?: string;
|
||||
websocket_enabled?: boolean;
|
||||
websocket_events?: string[];
|
||||
rabbitmq_enabled?: boolean;
|
||||
@@ -40,7 +46,7 @@ export class InstanceDto {
|
||||
typebot_delay_message?: number;
|
||||
typebot_unknown_message?: string;
|
||||
typebot_listening_from_me?: boolean;
|
||||
proxy?: string;
|
||||
proxy?: ProxyDto['proxy'];
|
||||
}
|
||||
|
||||
export class SetPresenceDto {
|
||||
@@ -1,4 +1,4 @@
|
||||
import { proto, WAPresence } from '@whiskeysockets/baileys';
|
||||
import { proto, WAPresence } from 'baileys';
|
||||
|
||||
export class Quoted {
|
||||
key: proto.IMessageKey;
|
||||
@@ -6,4 +6,5 @@ export class SettingsDto {
|
||||
read_messages?: boolean;
|
||||
read_status?: boolean;
|
||||
sync_full_history?: boolean;
|
||||
wavoipToken?: string;
|
||||
}
|
||||
@@ -3,12 +3,12 @@ import { NextFunction, Request, Response } from 'express';
|
||||
import jwt from 'jsonwebtoken';
|
||||
|
||||
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 { ForbiddenException, UnauthorizedException } from '../../exceptions';
|
||||
import { InstanceDto } from '../dto/instance.dto';
|
||||
import { repository } from '../server.module';
|
||||
import { JwtPayload } from '../services/auth.service';
|
||||
import { repository } from '../whatsapp.module';
|
||||
|
||||
const logger = new Logger('GUARD');
|
||||
|
||||
@@ -58,6 +58,11 @@ async function jwtGuard(req: Request, res: Response, next: NextFunction) {
|
||||
async function apikey(req: Request, _: Response, next: NextFunction) {
|
||||
const env = configService.get<Auth>('AUTHENTICATION').API_KEY;
|
||||
const key = req.get('apikey');
|
||||
const db = configService.get<Database>('DATABASE');
|
||||
|
||||
if (!key) {
|
||||
throw new UnauthorizedException();
|
||||
}
|
||||
|
||||
if (env.KEY === key) {
|
||||
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) {
|
||||
throw new ForbiddenException('Missing global api key', 'The global api key must be set');
|
||||
}
|
||||
const param = req.params as unknown as InstanceDto;
|
||||
|
||||
try {
|
||||
const param = req.params as unknown as InstanceDto;
|
||||
const instanceKey = await repository.auth.find(param.instanceName);
|
||||
if (instanceKey.apikey === key) {
|
||||
return next();
|
||||
if (param?.instanceName) {
|
||||
const instanceKey = await repository.auth.find(param.instanceName);
|
||||
if (instanceKey?.apikey === key) {
|
||||
return next();
|
||||
}
|
||||
} else {
|
||||
if (req.originalUrl.includes('/instance/fetchInstances') && db.ENABLED) {
|
||||
const instanceByKey = await repository.auth.findByKey(key);
|
||||
if (instanceByKey) {
|
||||
return next();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
logger.error(error);
|
||||
@@ -2,7 +2,7 @@ import { NextFunction, Request, Response } from 'express';
|
||||
import { existsSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
|
||||
import { configService, Database, Redis } from '../../config/env.config';
|
||||
import { CacheConf, configService, Database } from '../../config/env.config';
|
||||
import { INSTANCE_DIR } from '../../config/path.config';
|
||||
import {
|
||||
BadRequestException,
|
||||
@@ -12,17 +12,18 @@ import {
|
||||
} from '../../exceptions';
|
||||
import { dbserver } from '../../libs/db.connect';
|
||||
import { InstanceDto } from '../dto/instance.dto';
|
||||
import { cache, waMonitor } from '../whatsapp.module';
|
||||
import { cache, waMonitor } from '../server.module';
|
||||
|
||||
async function getInstance(instanceName: string) {
|
||||
try {
|
||||
const db = configService.get<Database>('DATABASE');
|
||||
const redisConf = configService.get<Redis>('REDIS');
|
||||
const cacheConf = configService.get<CacheConf>('CACHE');
|
||||
|
||||
const exists = !!waMonitor.waInstances[instanceName];
|
||||
|
||||
if (redisConf.ENABLED) {
|
||||
const keyExists = await cache.keyExists();
|
||||
if (cacheConf.REDIS.ENABLED && cacheConf.REDIS.SAVE_INSTANCES) {
|
||||
const keyExists = await cache.has(instanceName);
|
||||
|
||||
return exists || keyExists;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Logger } from '../../config/logger.config';
|
||||
import { Logger } from '../../../../config/logger.config';
|
||||
import { InstanceDto } from '../../../dto/instance.dto';
|
||||
import { ChamaaiDto } from '../dto/chamaai.dto';
|
||||
import { InstanceDto } from '../dto/instance.dto';
|
||||
import { ChamaaiService } from '../services/chamaai.service';
|
||||
|
||||
const logger = new Logger('ChamaaiController');
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Schema } from 'mongoose';
|
||||
|
||||
import { dbserver } from '../../libs/db.connect';
|
||||
import { dbserver } from '../../../../libs/db.connect';
|
||||
|
||||
export class ChamaaiRaw {
|
||||
_id?: string;
|
||||
@@ -1,10 +1,10 @@
|
||||
import { readFileSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
|
||||
import { ConfigService } from '../../config/env.config';
|
||||
import { Logger } from '../../config/logger.config';
|
||||
import { IInsert, Repository } from '../abstract/abstract.repository';
|
||||
import { ChamaaiRaw, IChamaaiModel } from '../models';
|
||||
import { ConfigService } from '../../../../config/env.config';
|
||||
import { Logger } from '../../../../config/logger.config';
|
||||
import { IInsert, Repository } from '../../../abstract/abstract.repository';
|
||||
import { ChamaaiRaw, IChamaaiModel } from '../../../models';
|
||||
|
||||
export class ChamaaiRepository extends Repository {
|
||||
constructor(private readonly chamaaiModel: IChamaaiModel, private readonly configService: ConfigService) {
|
||||
@@ -1,12 +1,12 @@
|
||||
import { RequestHandler, Router } from 'express';
|
||||
|
||||
import { Logger } from '../../config/logger.config';
|
||||
import { chamaaiSchema, instanceNameSchema } from '../../validate/validate.schema';
|
||||
import { RouterBroker } from '../abstract/abstract.router';
|
||||
import { Logger } from '../../../../config/logger.config';
|
||||
import { chamaaiSchema, instanceNameSchema } from '../../../../validate/validate.schema';
|
||||
import { RouterBroker } from '../../../abstract/abstract.router';
|
||||
import { InstanceDto } from '../../../dto/instance.dto';
|
||||
import { HttpStatus } from '../../../routes/index.router';
|
||||
import { chamaaiController } from '../../../server.module';
|
||||
import { ChamaaiDto } from '../dto/chamaai.dto';
|
||||
import { InstanceDto } from '../dto/instance.dto';
|
||||
import { chamaaiController } from '../whatsapp.module';
|
||||
import { HttpStatus } from './index.router';
|
||||
|
||||
const logger = new Logger('ChamaaiRouter');
|
||||
|
||||
@@ -2,13 +2,13 @@ import axios from 'axios';
|
||||
import { writeFileSync } from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
import { ConfigService, HttpServer } from '../../config/env.config';
|
||||
import { Logger } from '../../config/logger.config';
|
||||
import { ConfigService, HttpServer } from '../../../../config/env.config';
|
||||
import { Logger } from '../../../../config/logger.config';
|
||||
import { InstanceDto } from '../../../dto/instance.dto';
|
||||
import { ChamaaiRaw } from '../../../models';
|
||||
import { WAMonitoringService } from '../../../services/monitor.service';
|
||||
import { Events } from '../../../types/wa.types';
|
||||
import { ChamaaiDto } from '../dto/chamaai.dto';
|
||||
import { InstanceDto } from '../dto/instance.dto';
|
||||
import { ChamaaiRaw } from '../models';
|
||||
import { Events } from '../types/wa.types';
|
||||
import { WAMonitoringService } from './monitor.service';
|
||||
|
||||
export class ChamaaiService {
|
||||
constructor(private readonly waMonitor: WAMonitoringService, private readonly configService: ConfigService) {}
|
||||
35
src/api/integrations/chamaai/validate/chamaai.schema.ts
Normal file
35
src/api/integrations/chamaai/validate/chamaai.schema.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { JSONSchema7 } from 'json-schema';
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
const isNotEmpty = (...propertyNames: string[]): JSONSchema7 => {
|
||||
const properties = {};
|
||||
propertyNames.forEach(
|
||||
(property) =>
|
||||
(properties[property] = {
|
||||
minLength: 1,
|
||||
description: `The "${property}" cannot be empty`,
|
||||
}),
|
||||
);
|
||||
return {
|
||||
if: {
|
||||
propertyNames: {
|
||||
enum: [...propertyNames],
|
||||
},
|
||||
},
|
||||
then: { properties },
|
||||
};
|
||||
};
|
||||
|
||||
export const chamaaiSchema: JSONSchema7 = {
|
||||
$id: v4(),
|
||||
type: 'object',
|
||||
properties: {
|
||||
enabled: { type: 'boolean', enum: [true, false] },
|
||||
url: { type: 'string' },
|
||||
token: { type: 'string' },
|
||||
waNumber: { type: 'string' },
|
||||
answerByAudio: { type: 'boolean', enum: [true, false] },
|
||||
},
|
||||
required: ['enabled', 'url', 'token', 'waNumber', 'answerByAudio'],
|
||||
...isNotEmpty('enabled', 'url', 'token', 'waNumber', 'answerByAudio'),
|
||||
};
|
||||
@@ -1,15 +1,15 @@
|
||||
import { isURL } from 'class-validator';
|
||||
|
||||
import { ConfigService, HttpServer } from '../../config/env.config';
|
||||
import { Logger } from '../../config/logger.config';
|
||||
import { BadRequestException } from '../../exceptions';
|
||||
import { CacheEngine } from '../../libs/cacheengine';
|
||||
import { CacheEngine } from '../../../../cache/cacheengine';
|
||||
import { ConfigService, HttpServer } from '../../../../config/env.config';
|
||||
import { Logger } from '../../../../config/logger.config';
|
||||
import { BadRequestException } from '../../../../exceptions';
|
||||
import { InstanceDto } from '../../../dto/instance.dto';
|
||||
import { RepositoryBroker } from '../../../repository/repository.manager';
|
||||
import { waMonitor } from '../../../server.module';
|
||||
import { CacheService } from '../../../services/cache.service';
|
||||
import { ChatwootDto } from '../dto/chatwoot.dto';
|
||||
import { InstanceDto } from '../dto/instance.dto';
|
||||
import { RepositoryBroker } from '../repository/repository.manager';
|
||||
import { CacheService } from '../services/cache.service';
|
||||
import { ChatwootService } from '../services/chatwoot.service';
|
||||
import { waMonitor } from '../whatsapp.module';
|
||||
|
||||
const logger = new Logger('ChatwootController');
|
||||
|
||||
@@ -53,11 +53,15 @@ export class ChatwootController {
|
||||
data.conversation_pending = false;
|
||||
data.import_contacts = false;
|
||||
data.import_messages = false;
|
||||
data.merge_brazil_contacts = false;
|
||||
data.days_limit_import_messages = 0;
|
||||
data.auto_create = false;
|
||||
data.name_inbox = '';
|
||||
}
|
||||
|
||||
data.name_inbox = instance.instanceName;
|
||||
if (!data.name_inbox || data.name_inbox === '') {
|
||||
data.name_inbox = instance.instanceName;
|
||||
}
|
||||
|
||||
const result = await this.chatwootService.create(instance, data);
|
||||
|
||||
@@ -9,6 +9,7 @@ export class ChatwootDto {
|
||||
number?: string;
|
||||
reopen_conversation?: boolean;
|
||||
conversation_pending?: boolean;
|
||||
merge_brazil_contacts?: boolean;
|
||||
import_contacts?: boolean;
|
||||
import_messages?: boolean;
|
||||
days_limit_import_messages?: number;
|
||||
@@ -1,7 +1,7 @@
|
||||
import postgresql from 'pg';
|
||||
|
||||
import { Chatwoot, configService } from '../config/env.config';
|
||||
import { Logger } from '../config/logger.config';
|
||||
import { Chatwoot, configService } from '../../../../config/env.config';
|
||||
import { Logger } from '../../../../config/logger.config';
|
||||
|
||||
const { Pool } = postgresql;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Schema } from 'mongoose';
|
||||
|
||||
import { dbserver } from '../../libs/db.connect';
|
||||
import { dbserver } from '../../../../libs/db.connect';
|
||||
|
||||
export class ChatwootRaw {
|
||||
_id?: string;
|
||||
@@ -14,6 +14,7 @@ export class ChatwootRaw {
|
||||
number?: string;
|
||||
reopen_conversation?: boolean;
|
||||
conversation_pending?: boolean;
|
||||
merge_brazil_contacts?: boolean;
|
||||
import_contacts?: boolean;
|
||||
import_messages?: boolean;
|
||||
days_limit_import_messages?: number;
|
||||
@@ -31,6 +32,7 @@ const chatwootSchema = new Schema<ChatwootRaw>({
|
||||
number: { type: String, required: true },
|
||||
reopen_conversation: { type: Boolean, required: true },
|
||||
conversation_pending: { type: Boolean, required: true },
|
||||
merge_brazil_contacts: { type: Boolean, required: true },
|
||||
import_contacts: { type: Boolean, required: true },
|
||||
import_messages: { type: Boolean, required: true },
|
||||
days_limit_import_messages: { type: Number, required: true },
|
||||
@@ -1,10 +1,10 @@
|
||||
import { readFileSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
|
||||
import { ConfigService } from '../../config/env.config';
|
||||
import { Logger } from '../../config/logger.config';
|
||||
import { IInsert, Repository } from '../abstract/abstract.repository';
|
||||
import { ChatwootRaw, IChatwootModel } from '../models';
|
||||
import { ConfigService } from '../../../../config/env.config';
|
||||
import { Logger } from '../../../../config/logger.config';
|
||||
import { IInsert, Repository } from '../../../abstract/abstract.repository';
|
||||
import { ChatwootRaw, IChatwootModel } from '../../../models';
|
||||
|
||||
export class ChatwootRepository extends Repository {
|
||||
constructor(private readonly chatwootModel: IChatwootModel, private readonly configService: ConfigService) {
|
||||
@@ -1,12 +1,12 @@
|
||||
import { RequestHandler, Router } from 'express';
|
||||
|
||||
import { Logger } from '../../config/logger.config';
|
||||
import { chatwootSchema, instanceNameSchema } from '../../validate/validate.schema';
|
||||
import { RouterBroker } from '../abstract/abstract.router';
|
||||
import { Logger } from '../../../../config/logger.config';
|
||||
import { chatwootSchema, instanceNameSchema } from '../../../../validate/validate.schema';
|
||||
import { RouterBroker } from '../../../abstract/abstract.router';
|
||||
import { InstanceDto } from '../../../dto/instance.dto';
|
||||
import { HttpStatus } from '../../../routes/index.router';
|
||||
import { chatwootController } from '../../../server.module';
|
||||
import { ChatwootDto } from '../dto/chatwoot.dto';
|
||||
import { InstanceDto } from '../dto/instance.dto';
|
||||
import { chatwootController } from '../whatsapp.module';
|
||||
import { HttpStatus } from './index.router';
|
||||
|
||||
const logger = new Logger('ChatwootRouter');
|
||||
|
||||
@@ -1,24 +1,33 @@
|
||||
import ChatwootClient, { ChatwootAPIConfig, contact, conversation, generic_id, inbox } from '@figuro/chatwoot-sdk';
|
||||
import ChatwootClient, {
|
||||
ChatwootAPIConfig,
|
||||
contact,
|
||||
contact_inboxes,
|
||||
conversation,
|
||||
conversation_show,
|
||||
generic_id,
|
||||
inbox,
|
||||
} from '@figuro/chatwoot-sdk';
|
||||
import { request as chatwootRequest } from '@figuro/chatwoot-sdk/dist/core/request';
|
||||
import axios from 'axios';
|
||||
import { proto } from 'baileys';
|
||||
import FormData from 'form-data';
|
||||
import { createReadStream, unlinkSync, writeFileSync } from 'fs';
|
||||
import Jimp from 'jimp';
|
||||
import mimeTypes from 'mime-types';
|
||||
import path from 'path';
|
||||
|
||||
import { Chatwoot, ConfigService, HttpServer } from '../../config/env.config';
|
||||
import { Logger } from '../../config/logger.config';
|
||||
import { chatwootImport } from '../../utils/chatwoot-import-helper';
|
||||
import i18next from '../../utils/i18n';
|
||||
import { ICache } from '../abstract/abstract.cache';
|
||||
import { Chatwoot, ConfigService, HttpServer } from '../../../../config/env.config';
|
||||
import { Logger } from '../../../../config/logger.config';
|
||||
import i18next from '../../../../utils/i18n';
|
||||
import { ICache } from '../../../abstract/abstract.cache';
|
||||
import { InstanceDto } from '../../../dto/instance.dto';
|
||||
import { Options, Quoted, SendAudioDto, SendMediaDto, SendTextDto } from '../../../dto/sendMessage.dto';
|
||||
import { ChatwootRaw, ContactRaw, MessageRaw } from '../../../models';
|
||||
import { RepositoryBroker } from '../../../repository/repository.manager';
|
||||
import { WAMonitoringService } from '../../../services/monitor.service';
|
||||
import { Events } from '../../../types/wa.types';
|
||||
import { ChatwootDto } from '../dto/chatwoot.dto';
|
||||
import { InstanceDto } from '../dto/instance.dto';
|
||||
import { Options, Quoted, SendAudioDto, SendMediaDto, SendTextDto } from '../dto/sendMessage.dto';
|
||||
import { ChatwootRaw, ContactRaw, MessageRaw } from '../models';
|
||||
import { RepositoryBroker } from '../repository/repository.manager';
|
||||
import { Events } from '../types/wa.types';
|
||||
import { WAMonitoringService } from './monitor.service';
|
||||
import { chatwootImport } from '../utils/chatwoot-import-helper';
|
||||
|
||||
export class ChatwootService {
|
||||
private readonly logger = new Logger(ChatwootService.name);
|
||||
@@ -77,12 +86,14 @@ export class ChatwootService {
|
||||
return client;
|
||||
}
|
||||
|
||||
public getClientCwConfig(): ChatwootAPIConfig {
|
||||
public getClientCwConfig(): ChatwootAPIConfig & { name_inbox: string; merge_brazil_contacts: boolean } {
|
||||
return {
|
||||
basePath: this.provider.url,
|
||||
with_credentials: true,
|
||||
credentials: 'include',
|
||||
token: this.provider.token,
|
||||
name_inbox: this.provider.name_inbox,
|
||||
merge_brazil_contacts: this.provider.merge_brazil_contacts,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -102,7 +113,7 @@ export class ChatwootService {
|
||||
|
||||
await this.initInstanceChatwoot(
|
||||
instance,
|
||||
instance.instanceName.split('-cwId-')[0],
|
||||
data.name_inbox ?? instance.instanceName.split('-cwId-')[0],
|
||||
`${urlServer}/chatwoot/webhook/${encodeURIComponent(instance.instanceName)}`,
|
||||
true,
|
||||
data.number,
|
||||
@@ -408,10 +419,48 @@ export class ChatwootService {
|
||||
}
|
||||
}
|
||||
|
||||
private async mergeBrazilianContacts(contacts: any[]) {
|
||||
try {
|
||||
//sdk chatwoot não tem função merge
|
||||
this.logger.verbose('merging contacts');
|
||||
const contact = await chatwootRequest(this.getClientCwConfig(), {
|
||||
method: 'POST',
|
||||
url: `/api/v1/accounts/${this.provider.account_id}/actions/contact_merge`,
|
||||
body: {
|
||||
base_contact_id: contacts.find((contact) => contact.phone_number.length === 14)?.id,
|
||||
mergee_contact_id: contacts.find((contact) => contact.phone_number.length === 13)?.id,
|
||||
},
|
||||
});
|
||||
|
||||
return contact;
|
||||
} catch {
|
||||
this.logger.error('Error merging contacts');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private findContactInContactList(contacts: any[], query: string) {
|
||||
const phoneNumbers = this.getNumbers(query);
|
||||
const searchableFields = this.getSearchableFields();
|
||||
|
||||
// eslint-disable-next-line prettier/prettier
|
||||
if (contacts.length === 2 && this.getClientCwConfig().merge_brazil_contacts && query.startsWith('+55')) {
|
||||
const contact = this.mergeBrazilianContacts(contacts);
|
||||
if (contact) {
|
||||
return contact;
|
||||
}
|
||||
}
|
||||
|
||||
const phone = phoneNumbers.reduce(
|
||||
(savedNumber, number) => (number.length > savedNumber.length ? number : savedNumber),
|
||||
'',
|
||||
);
|
||||
|
||||
const contact_with9 = contacts.find((contact) => contact.phone_number === phone);
|
||||
if (contact_with9) {
|
||||
return contact_with9;
|
||||
}
|
||||
|
||||
for (const contact of contacts) {
|
||||
for (const field of searchableFields) {
|
||||
if (contact[field] && phoneNumbers.includes(contact[field])) {
|
||||
@@ -439,7 +488,7 @@ export class ChatwootService {
|
||||
}
|
||||
|
||||
private getSearchableFields() {
|
||||
return ['phone_number', 'identifier'];
|
||||
return ['phone_number'];
|
||||
}
|
||||
|
||||
private getFilterPayload(query: string) {
|
||||
@@ -453,7 +502,7 @@ export class ChatwootService {
|
||||
const queryOperator = fieldsToSearch.length - 1 === index1 && numbers.length - 1 === index2 ? null : 'OR';
|
||||
filterPayload.push({
|
||||
attribute_key: field,
|
||||
filter_operator: field == 'phone_number' ? 'equal_to' : 'contains',
|
||||
filter_operator: 'equal_to',
|
||||
values: [number.replace('+', '')],
|
||||
query_operator: queryOperator,
|
||||
});
|
||||
@@ -551,53 +600,44 @@ export class ChatwootService {
|
||||
|
||||
const picture_url = await this.waMonitor.waInstances[instance.instanceName].profilePicture(chatId);
|
||||
|
||||
const findContact = await this.findContact(instance, chatId);
|
||||
let contact = await this.findContact(instance, chatId);
|
||||
|
||||
let contact: any;
|
||||
if (body.key.fromMe) {
|
||||
if (findContact) {
|
||||
contact = await this.updateContact(instance, findContact.id, {
|
||||
avatar_url: picture_url.profilePictureUrl || null,
|
||||
});
|
||||
} else {
|
||||
const jid = isGroup ? null : body.key.remoteJid;
|
||||
contact = await this.createContact(
|
||||
instance,
|
||||
chatId,
|
||||
filterInbox.id,
|
||||
isGroup,
|
||||
nameContact,
|
||||
picture_url.profilePictureUrl || null,
|
||||
jid,
|
||||
);
|
||||
if (contact) {
|
||||
if (!body.key.fromMe) {
|
||||
const waProfilePictureFile =
|
||||
picture_url?.profilePictureUrl?.split('#')[0].split('?')[0].split('/').pop() || '';
|
||||
const chatwootProfilePictureFile = contact?.thumbnail?.split('#')[0].split('?')[0].split('/').pop() || '';
|
||||
const pictureNeedsUpdate = waProfilePictureFile !== chatwootProfilePictureFile;
|
||||
const nameNeedsUpdate =
|
||||
!contact.name ||
|
||||
contact.name === chatId ||
|
||||
(`+${chatId}`.startsWith('+55')
|
||||
? this.getNumbers(`+${chatId}`).some(
|
||||
(v) => contact.name === v || contact.name === v.substring(3) || contact.name === v.substring(1),
|
||||
)
|
||||
: false);
|
||||
|
||||
const contactNeedsUpdate = pictureNeedsUpdate || nameNeedsUpdate;
|
||||
if (contactNeedsUpdate) {
|
||||
this.logger.verbose('update contact in chatwoot');
|
||||
contact = await this.updateContact(instance, contact.id, {
|
||||
...(nameNeedsUpdate && { name: nameContact }),
|
||||
...(waProfilePictureFile === '' && { avatar: null }),
|
||||
...(pictureNeedsUpdate && { avatar_url: picture_url?.profilePictureUrl }),
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (findContact) {
|
||||
if (!findContact.name || findContact.name === chatId) {
|
||||
contact = await this.updateContact(instance, findContact.id, {
|
||||
name: nameContact,
|
||||
avatar_url: picture_url.profilePictureUrl || null,
|
||||
});
|
||||
} else {
|
||||
contact = await this.updateContact(instance, findContact.id, {
|
||||
avatar_url: picture_url.profilePictureUrl || null,
|
||||
});
|
||||
}
|
||||
if (!contact) {
|
||||
contact = await this.findContact(instance, chatId);
|
||||
}
|
||||
} else {
|
||||
const jid = isGroup ? null : body.key.remoteJid;
|
||||
contact = await this.createContact(
|
||||
instance,
|
||||
chatId,
|
||||
filterInbox.id,
|
||||
isGroup,
|
||||
nameContact,
|
||||
picture_url.profilePictureUrl || null,
|
||||
jid,
|
||||
);
|
||||
}
|
||||
const jid = isGroup ? null : body.key.remoteJid;
|
||||
contact = await this.createContact(
|
||||
instance,
|
||||
chatId,
|
||||
filterInbox.id,
|
||||
isGroup,
|
||||
nameContact,
|
||||
picture_url.profilePictureUrl || null,
|
||||
jid,
|
||||
);
|
||||
}
|
||||
|
||||
if (!contact) {
|
||||
@@ -607,20 +647,13 @@ export class ChatwootService {
|
||||
|
||||
const contactId = contact?.payload?.id || contact?.payload?.contact?.id || contact?.id;
|
||||
|
||||
if (!body.key.fromMe && contact.name === chatId && nameContact !== chatId) {
|
||||
this.logger.verbose('update contact name in chatwoot');
|
||||
await this.updateContact(instance, contactId, {
|
||||
name: nameContact,
|
||||
});
|
||||
}
|
||||
|
||||
this.logger.verbose('get contact conversations in chatwoot');
|
||||
const contactConversations = (await client.contacts.listConversations({
|
||||
accountId: this.provider.account_id,
|
||||
id: contactId,
|
||||
})) as any;
|
||||
|
||||
if (contactConversations) {
|
||||
if (contactConversations?.payload?.length) {
|
||||
let conversation: any;
|
||||
if (this.provider.reopen_conversation) {
|
||||
conversation = contactConversations.payload.find((conversation) => conversation.inbox_id == filterInbox.id);
|
||||
@@ -702,7 +735,11 @@ export class ChatwootService {
|
||||
}
|
||||
|
||||
this.logger.verbose('find inbox by name');
|
||||
const findByName = inbox.payload.find((inbox) => inbox.name === instance.instanceName.split('-cwId-')[0]);
|
||||
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) {
|
||||
this.logger.warn('inbox not found');
|
||||
@@ -779,26 +816,15 @@ export class ChatwootService {
|
||||
return null;
|
||||
}
|
||||
|
||||
const payload = [
|
||||
['inbox_id', inbox.id.toString()],
|
||||
['contact_id', contact.id.toString()],
|
||||
['status', 'open'],
|
||||
];
|
||||
const conversations = (await client.contacts.listConversations({
|
||||
accountId: this.provider.account_id,
|
||||
id: contact.id,
|
||||
})) as any;
|
||||
|
||||
return (
|
||||
(
|
||||
(await client.conversations.filter({
|
||||
accountId: this.provider.account_id,
|
||||
payload: payload.map((item, i, payload) => {
|
||||
return {
|
||||
attribute_key: item[0],
|
||||
filter_operator: 'equal_to',
|
||||
values: [item[1]],
|
||||
query_operator: i < payload.length - 1 ? 'AND' : null,
|
||||
};
|
||||
}),
|
||||
})) as { payload: conversation[] }
|
||||
).payload[0] || undefined
|
||||
conversations.payload.find(
|
||||
(conversation) => conversation.inbox_id === inbox.id && conversation.status === 'open',
|
||||
) || undefined
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1069,6 +1095,10 @@ export class ChatwootService {
|
||||
return messageSent;
|
||||
}
|
||||
|
||||
if (type === 'image' && parsedMedia && parsedMedia?.ext === '.gif') {
|
||||
type = 'document';
|
||||
}
|
||||
|
||||
this.logger.verbose('send media to instance: ' + waInstance.instanceName);
|
||||
const data: SendMediaDto = {
|
||||
number: number,
|
||||
@@ -1098,6 +1128,26 @@ export class ChatwootService {
|
||||
}
|
||||
}
|
||||
|
||||
public async onSendMessageError(instance: InstanceDto, conversation: number, error?: string) {
|
||||
const client = await this.clientCw(instance);
|
||||
|
||||
if (!client) {
|
||||
return;
|
||||
}
|
||||
|
||||
client.messages.create({
|
||||
accountId: this.provider.account_id,
|
||||
conversationId: conversation,
|
||||
data: {
|
||||
content: i18next.t('cw.message.notsent', {
|
||||
error: error?.length > 0 ? `_${error}_` : '',
|
||||
}),
|
||||
message_type: 'outgoing',
|
||||
private: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
public async receiveWebhook(instance: InstanceDto, body: any) {
|
||||
try {
|
||||
await new Promise((resolve) => setTimeout(resolve, 500));
|
||||
@@ -1266,6 +1316,11 @@ export class ChatwootService {
|
||||
return { message: 'bot' };
|
||||
}
|
||||
|
||||
if (!waInstance && body.conversation?.id) {
|
||||
this.onSendMessageError(instance, body.conversation?.id, 'Instance not found');
|
||||
return { message: 'bot' };
|
||||
}
|
||||
|
||||
this.logger.verbose('Format message to send');
|
||||
let formatText: string;
|
||||
if (senderName === null || senderName === undefined) {
|
||||
@@ -1302,6 +1357,9 @@ export class ChatwootService {
|
||||
formatText,
|
||||
options,
|
||||
);
|
||||
if (!messageSent && body.conversation?.id) {
|
||||
this.onSendMessageError(instance, body.conversation?.id);
|
||||
}
|
||||
|
||||
this.updateChatwootMessageId(
|
||||
{
|
||||
@@ -1335,23 +1393,34 @@ export class ChatwootService {
|
||||
},
|
||||
};
|
||||
|
||||
const messageSent = await waInstance?.textMessage(data, true);
|
||||
let messageSent: MessageRaw | proto.WebMessageInfo;
|
||||
try {
|
||||
messageSent = await waInstance?.textMessage(data, true);
|
||||
if (!messageSent) {
|
||||
throw new Error('Message not sent');
|
||||
}
|
||||
|
||||
this.updateChatwootMessageId(
|
||||
{
|
||||
...messageSent,
|
||||
owner: instance.instanceName,
|
||||
},
|
||||
{
|
||||
messageId: body.id,
|
||||
inboxId: body.inbox?.id,
|
||||
conversationId: body.conversation?.id,
|
||||
contactInbox: {
|
||||
sourceId: body.conversation?.contact_inbox?.source_id,
|
||||
this.updateChatwootMessageId(
|
||||
{
|
||||
...messageSent,
|
||||
owner: instance.instanceName,
|
||||
},
|
||||
},
|
||||
instance,
|
||||
);
|
||||
{
|
||||
messageId: body.id,
|
||||
inboxId: body.inbox?.id,
|
||||
conversationId: body.conversation?.id,
|
||||
contactInbox: {
|
||||
sourceId: body.conversation?.contact_inbox?.source_id,
|
||||
},
|
||||
},
|
||||
instance,
|
||||
);
|
||||
} catch (error) {
|
||||
if (!messageSent && body.conversation?.id) {
|
||||
this.onSendMessageError(instance, body.conversation?.id, error.toString());
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1774,6 +1843,13 @@ export class ChatwootService {
|
||||
return;
|
||||
}
|
||||
|
||||
// fix when receiving/sending messages from whatsapp desktop with ephemeral messages enabled
|
||||
if (body.message?.ephemeralMessage?.message) {
|
||||
body.message = {
|
||||
...body.message?.ephemeralMessage?.message,
|
||||
};
|
||||
}
|
||||
|
||||
this.logger.verbose('get conversation message');
|
||||
|
||||
// Whatsapp to Chatwoot
|
||||
@@ -1830,7 +1906,8 @@ export class ChatwootService {
|
||||
|
||||
let nameFile: string;
|
||||
const messageBody = body?.message[body?.messageType];
|
||||
const originalFilename = messageBody?.fileName || messageBody?.message?.documentMessage?.fileName;
|
||||
const originalFilename =
|
||||
messageBody?.fileName || messageBody?.filename || messageBody?.message?.documentMessage?.fileName;
|
||||
if (originalFilename) {
|
||||
const parsedFile = path.parse(originalFilename);
|
||||
if (parsedFile.name && parsedFile.ext) {
|
||||
@@ -2123,12 +2200,13 @@ export class ChatwootService {
|
||||
};
|
||||
|
||||
if (!sourceId && inbox) {
|
||||
const contact = (await this.findContact(
|
||||
instance,
|
||||
this.getNumberFromRemoteJid(body.key.remoteJid),
|
||||
)) as contact;
|
||||
const contactInbox = contact?.contact_inboxes?.find((contactInbox) => contactInbox?.inbox?.id === inbox.id);
|
||||
sourceId = contactInbox?.source_id;
|
||||
const conversation = (await client.conversations.get({
|
||||
accountId: this.provider.account_id,
|
||||
conversationId: conversationId,
|
||||
})) as conversation_show & {
|
||||
last_non_activity_message: { conversation: { contact_inbox: contact_inboxes } };
|
||||
};
|
||||
sourceId = conversation.last_non_activity_message?.conversation?.contact_inbox?.source_id;
|
||||
}
|
||||
|
||||
if (sourceId && inbox?.inbox_identifier) {
|
||||
@@ -1,12 +1,12 @@
|
||||
import { inbox } from '@figuro/chatwoot-sdk';
|
||||
import { proto } from '@whiskeysockets/baileys';
|
||||
import { proto } from 'baileys';
|
||||
|
||||
import { Chatwoot, configService } from '../config/env.config';
|
||||
import { Logger } from '../config/logger.config';
|
||||
import { InstanceDto } from '../../../../api/dto/instance.dto';
|
||||
import { ChatwootRaw, ContactRaw, MessageRaw } from '../../../../api/models';
|
||||
import { Chatwoot, configService } from '../../../../config/env.config';
|
||||
import { Logger } from '../../../../config/logger.config';
|
||||
import { postgresClient } from '../libs/postgres.client';
|
||||
import { InstanceDto } from '../whatsapp/dto/instance.dto';
|
||||
import { ChatwootRaw, ContactRaw, MessageRaw } from '../whatsapp/models';
|
||||
import { ChatwootService } from '../whatsapp/services/chatwoot.service';
|
||||
import { ChatwootService } from '../services/chatwoot.service';
|
||||
|
||||
type ChatwootUser = {
|
||||
user_type: string;
|
||||
44
src/api/integrations/chatwoot/validate/chatwoot.schema.ts
Normal file
44
src/api/integrations/chatwoot/validate/chatwoot.schema.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import { JSONSchema7 } from 'json-schema';
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
const isNotEmpty = (...propertyNames: string[]): JSONSchema7 => {
|
||||
const properties = {};
|
||||
propertyNames.forEach(
|
||||
(property) =>
|
||||
(properties[property] = {
|
||||
minLength: 1,
|
||||
description: `The "${property}" cannot be empty`,
|
||||
}),
|
||||
);
|
||||
return {
|
||||
if: {
|
||||
propertyNames: {
|
||||
enum: [...propertyNames],
|
||||
},
|
||||
},
|
||||
then: { properties },
|
||||
};
|
||||
};
|
||||
|
||||
export const chatwootSchema: JSONSchema7 = {
|
||||
$id: v4(),
|
||||
type: 'object',
|
||||
properties: {
|
||||
enabled: { type: 'boolean', enum: [true, false] },
|
||||
account_id: { type: 'string' },
|
||||
token: { type: 'string' },
|
||||
url: { type: 'string' },
|
||||
sign_msg: { type: 'boolean', enum: [true, false] },
|
||||
sign_delimiter: { type: ['string', 'null'] },
|
||||
name_inbox: { type: ['string', 'null'] },
|
||||
reopen_conversation: { type: 'boolean', enum: [true, false] },
|
||||
conversation_pending: { type: 'boolean', enum: [true, false] },
|
||||
auto_create: { type: 'boolean', enum: [true, false] },
|
||||
import_contacts: { type: 'boolean', enum: [true, false] },
|
||||
merge_brazil_contacts: { type: 'boolean', enum: [true, false] },
|
||||
import_messages: { type: 'boolean', enum: [true, false] },
|
||||
days_limit_import_messages: { type: 'number' },
|
||||
},
|
||||
required: ['enabled', 'account_id', 'token', 'url', 'sign_msg', 'reopen_conversation', 'conversation_pending'],
|
||||
...isNotEmpty('account_id', 'token', 'url', 'sign_msg', 'reopen_conversation', 'conversation_pending'),
|
||||
};
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Logger } from '../../config/logger.config';
|
||||
import { InstanceDto } from '../dto/instance.dto';
|
||||
import { Logger } from '../../../../config/logger.config';
|
||||
import { InstanceDto } from '../../../dto/instance.dto';
|
||||
import { RabbitmqDto } from '../dto/rabbitmq.dto';
|
||||
import { RabbitmqService } from '../services/rabbitmq.service';
|
||||
|
||||
246
src/api/integrations/rabbitmq/libs/amqp.server.ts
Normal file
246
src/api/integrations/rabbitmq/libs/amqp.server.ts
Normal file
@@ -0,0 +1,246 @@
|
||||
import * as amqp from 'amqplib/callback_api';
|
||||
|
||||
import { configService, Rabbitmq } from '../../../../config/env.config';
|
||||
import { Logger } from '../../../../config/logger.config';
|
||||
|
||||
const logger = new Logger('AMQP');
|
||||
|
||||
let amqpChannel: amqp.Channel | null = null;
|
||||
let amqpConnection: amqp.Connection | null = null;
|
||||
let reconnectAttempts = 0;
|
||||
const maxReconnectAttempts = 10;
|
||||
const reconnectInterval = 5000; // 5 segundos
|
||||
|
||||
type ResolveCallback = () => void;
|
||||
type RejectCallback = (error: Error) => void;
|
||||
|
||||
export const initAMQP = () => {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
connectToRabbitMQ(resolve, reject);
|
||||
});
|
||||
};
|
||||
|
||||
const connectToRabbitMQ = (resolve?: ResolveCallback, reject?: RejectCallback) => {
|
||||
const uri = configService.get<Rabbitmq>('RABBITMQ').URI;
|
||||
amqp.connect(uri, (error, connection) => {
|
||||
if (error) {
|
||||
logger.error(`Failed to connect to RabbitMQ: ${error.message}`);
|
||||
handleConnectionError(error, resolve, reject);
|
||||
return;
|
||||
}
|
||||
|
||||
reconnectAttempts = 0;
|
||||
amqpConnection = connection;
|
||||
|
||||
connection.on('error', (err) => {
|
||||
logger.error(`RabbitMQ connection error: ${err.message}`);
|
||||
scheduleReconnect();
|
||||
});
|
||||
|
||||
connection.on('close', () => {
|
||||
logger.warn('RabbitMQ connection closed unexpectedly');
|
||||
scheduleReconnect();
|
||||
});
|
||||
|
||||
createChannel(connection, resolve, reject);
|
||||
});
|
||||
};
|
||||
|
||||
const createChannel = (connection: amqp.Connection, resolve?: ResolveCallback, reject?: RejectCallback) => {
|
||||
connection.createChannel((channelError, channel) => {
|
||||
if (channelError) {
|
||||
logger.error(`Failed to create channel: ${channelError.message}`);
|
||||
if (reject) {
|
||||
reject(channelError);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const exchangeName = 'evolution_exchange';
|
||||
|
||||
channel.assertExchange(exchangeName, 'topic', {
|
||||
durable: true,
|
||||
autoDelete: false,
|
||||
});
|
||||
|
||||
channel.on('error', (err) => {
|
||||
logger.error(`RabbitMQ channel error: ${err.message}`);
|
||||
amqpChannel = null;
|
||||
createChannel(connection);
|
||||
});
|
||||
|
||||
channel.on('close', () => {
|
||||
logger.warn('RabbitMQ channel closed');
|
||||
amqpChannel = null;
|
||||
createChannel(connection);
|
||||
});
|
||||
|
||||
amqpChannel = channel;
|
||||
|
||||
logger.info('AMQP initialized');
|
||||
if (resolve) {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const scheduleReconnect = () => {
|
||||
if (reconnectAttempts >= maxReconnectAttempts) {
|
||||
logger.error(`Exceeded maximum ${maxReconnectAttempts} reconnection attempts to RabbitMQ`);
|
||||
return;
|
||||
}
|
||||
|
||||
amqpChannel = null;
|
||||
|
||||
if (amqpConnection) {
|
||||
try {
|
||||
amqpConnection.close();
|
||||
} catch (err) {
|
||||
// Ignora erro ao fechar conexão que já pode estar fechada
|
||||
}
|
||||
amqpConnection = null;
|
||||
}
|
||||
|
||||
reconnectAttempts++;
|
||||
const delay = reconnectInterval * Math.pow(1.5, reconnectAttempts - 1); // Backoff exponencial
|
||||
|
||||
logger.info(`Reconnection attempt ${reconnectAttempts} to RabbitMQ in ${delay}ms`);
|
||||
|
||||
setTimeout(() => {
|
||||
connectToRabbitMQ();
|
||||
}, delay);
|
||||
};
|
||||
|
||||
const handleConnectionError = (error: Error, resolve?: ResolveCallback, reject?: RejectCallback) => {
|
||||
if (reject && reconnectAttempts === 0) {
|
||||
// Na inicialização, rejeitar a Promise se for a primeira tentativa
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
|
||||
scheduleReconnect();
|
||||
};
|
||||
|
||||
export const getAMQP = (): amqp.Channel | null => {
|
||||
return amqpChannel;
|
||||
};
|
||||
|
||||
export const initGlobalQueues = () => {
|
||||
logger.info('Initializing global queues');
|
||||
const rabbitmqConfig = configService.get<Rabbitmq>('RABBITMQ');
|
||||
const events = rabbitmqConfig.EVENTS;
|
||||
const prefixKey = rabbitmqConfig.PREFIX_KEY;
|
||||
const messageTtl = rabbitmqConfig.MESSAGE_TTL;
|
||||
const maxLength = rabbitmqConfig.MAX_LENGTH;
|
||||
const maxLengthBytes = rabbitmqConfig.MAX_LENGTH_BYTES;
|
||||
|
||||
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 =
|
||||
prefixKey !== ''
|
||||
? `${prefixKey}.${event.replace(/_/g, '.').toLowerCase()}`
|
||||
: `${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',
|
||||
'x-message-ttl': messageTtl,
|
||||
'x-max-length': maxLength,
|
||||
'x-max-length-bytes': maxLengthBytes,
|
||||
'x-overflow': 'reject-publish',
|
||||
},
|
||||
});
|
||||
|
||||
amqp.bindQueue(queueName, exchangeName, event);
|
||||
});
|
||||
};
|
||||
|
||||
export const initQueues = (instanceName: string, events: string[]) => {
|
||||
if (!events || !events.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
const rabbitmqConfig = configService.get<Rabbitmq>('RABBITMQ');
|
||||
const messageTtl = rabbitmqConfig.MESSAGE_TTL;
|
||||
const maxLength = rabbitmqConfig.MAX_LENGTH;
|
||||
const maxLengthBytes = rabbitmqConfig.MAX_LENGTH_BYTES;
|
||||
|
||||
const queues = events.map((event) => {
|
||||
return `${event.replace(/_/g, '.').toLowerCase()}`;
|
||||
});
|
||||
|
||||
queues.forEach((event) => {
|
||||
const amqp = getAMQP();
|
||||
const exchangeName = instanceName ?? 'evolution_exchange';
|
||||
|
||||
amqp.assertExchange(exchangeName, 'topic', {
|
||||
durable: true,
|
||||
autoDelete: false,
|
||||
});
|
||||
|
||||
const queueName = `${instanceName}.${event}`;
|
||||
|
||||
amqp.assertQueue(queueName, {
|
||||
durable: true,
|
||||
autoDelete: false,
|
||||
arguments: {
|
||||
'x-queue-type': 'quorum',
|
||||
'x-message-ttl': messageTtl,
|
||||
'x-max-length': maxLength,
|
||||
'x-max-length-bytes': maxLengthBytes,
|
||||
'x-overflow': 'reject-publish',
|
||||
},
|
||||
});
|
||||
|
||||
amqp.bindQueue(queueName, exchangeName, event);
|
||||
});
|
||||
};
|
||||
|
||||
export const removeQueues = (instanceName: string, events: string[]) => {
|
||||
if (!events || !events.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
const channel = getAMQP();
|
||||
|
||||
const queues = events.map((event) => {
|
||||
return `${event.replace(/_/g, '.').toLowerCase()}`;
|
||||
});
|
||||
|
||||
const exchangeName = instanceName ?? 'evolution_exchange';
|
||||
|
||||
queues.forEach((event) => {
|
||||
const amqp = getAMQP();
|
||||
|
||||
amqp.assertExchange(exchangeName, 'topic', {
|
||||
durable: true,
|
||||
autoDelete: false,
|
||||
});
|
||||
|
||||
const queueName = `${instanceName}.${event}`;
|
||||
|
||||
amqp.deleteQueue(queueName);
|
||||
});
|
||||
|
||||
channel.deleteExchange(exchangeName);
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Schema } from 'mongoose';
|
||||
|
||||
import { dbserver } from '../../libs/db.connect';
|
||||
import { dbserver } from '../../../../libs/db.connect';
|
||||
|
||||
export class RabbitmqRaw {
|
||||
_id?: string;
|
||||
@@ -1,10 +1,10 @@
|
||||
import { readFileSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
|
||||
import { ConfigService } from '../../config/env.config';
|
||||
import { Logger } from '../../config/logger.config';
|
||||
import { IInsert, Repository } from '../abstract/abstract.repository';
|
||||
import { IRabbitmqModel, RabbitmqRaw } from '../models';
|
||||
import { ConfigService } from '../../../../config/env.config';
|
||||
import { Logger } from '../../../../config/logger.config';
|
||||
import { IInsert, Repository } from '../../../abstract/abstract.repository';
|
||||
import { IRabbitmqModel, RabbitmqRaw } from '../../../models';
|
||||
|
||||
export class RabbitmqRepository extends Repository {
|
||||
constructor(private readonly rabbitmqModel: IRabbitmqModel, private readonly configService: ConfigService) {
|
||||
@@ -1,12 +1,12 @@
|
||||
import { RequestHandler, Router } from 'express';
|
||||
|
||||
import { Logger } from '../../config/logger.config';
|
||||
import { instanceNameSchema, rabbitmqSchema } from '../../validate/validate.schema';
|
||||
import { RouterBroker } from '../abstract/abstract.router';
|
||||
import { InstanceDto } from '../dto/instance.dto';
|
||||
import { Logger } from '../../../../config/logger.config';
|
||||
import { instanceNameSchema, rabbitmqSchema } from '../../../../validate/validate.schema';
|
||||
import { RouterBroker } from '../../../abstract/abstract.router';
|
||||
import { InstanceDto } from '../../../dto/instance.dto';
|
||||
import { HttpStatus } from '../../../routes/index.router';
|
||||
import { rabbitmqController } from '../../../server.module';
|
||||
import { RabbitmqDto } from '../dto/rabbitmq.dto';
|
||||
import { rabbitmqController } from '../whatsapp.module';
|
||||
import { HttpStatus } from './index.router';
|
||||
|
||||
const logger = new Logger('RabbitmqRouter');
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Logger } from '../../config/logger.config';
|
||||
import { initQueues } from '../../libs/amqp.server';
|
||||
import { InstanceDto } from '../dto/instance.dto';
|
||||
import { Logger } from '../../../../config/logger.config';
|
||||
import { InstanceDto } from '../../../dto/instance.dto';
|
||||
import { RabbitmqRaw } from '../../../models';
|
||||
import { WAMonitoringService } from '../../../services/monitor.service';
|
||||
import { RabbitmqDto } from '../dto/rabbitmq.dto';
|
||||
import { RabbitmqRaw } from '../models';
|
||||
import { WAMonitoringService } from './monitor.service';
|
||||
import { initQueues } from '../libs/amqp.server';
|
||||
|
||||
export class RabbitmqService {
|
||||
constructor(private readonly waMonitor: WAMonitoringService) {}
|
||||
66
src/api/integrations/rabbitmq/validate/rabbitmq.schema.ts
Normal file
66
src/api/integrations/rabbitmq/validate/rabbitmq.schema.ts
Normal file
@@ -0,0 +1,66 @@
|
||||
import { JSONSchema7 } from 'json-schema';
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
const isNotEmpty = (...propertyNames: string[]): JSONSchema7 => {
|
||||
const properties = {};
|
||||
propertyNames.forEach(
|
||||
(property) =>
|
||||
(properties[property] = {
|
||||
minLength: 1,
|
||||
description: `The "${property}" cannot be empty`,
|
||||
}),
|
||||
);
|
||||
return {
|
||||
if: {
|
||||
propertyNames: {
|
||||
enum: [...propertyNames],
|
||||
},
|
||||
},
|
||||
then: { properties },
|
||||
};
|
||||
};
|
||||
|
||||
export const rabbitmqSchema: JSONSchema7 = {
|
||||
$id: v4(),
|
||||
type: 'object',
|
||||
properties: {
|
||||
enabled: { type: 'boolean', enum: [true, false] },
|
||||
events: {
|
||||
type: 'array',
|
||||
minItems: 0,
|
||||
items: {
|
||||
type: 'string',
|
||||
enum: [
|
||||
'APPLICATION_STARTUP',
|
||||
'QRCODE_UPDATED',
|
||||
'MESSAGES_SET',
|
||||
'MESSAGES_UPSERT',
|
||||
'MESSAGES_UPDATE',
|
||||
'MESSAGES_DELETE',
|
||||
'SEND_MESSAGE',
|
||||
'CONTACTS_SET',
|
||||
'CONTACTS_UPSERT',
|
||||
'CONTACTS_UPDATE',
|
||||
'PRESENCE_UPDATE',
|
||||
'CHATS_SET',
|
||||
'CHATS_UPSERT',
|
||||
'CHATS_UPDATE',
|
||||
'CHATS_DELETE',
|
||||
'GROUPS_UPSERT',
|
||||
'GROUP_UPDATE',
|
||||
'GROUP_PARTICIPANTS_UPDATE',
|
||||
'CONNECTION_UPDATE',
|
||||
'LABELS_EDIT',
|
||||
'LABELS_ASSOCIATION',
|
||||
'CALL',
|
||||
'NEW_JWT_TOKEN',
|
||||
'TYPEBOT_START',
|
||||
'TYPEBOT_CHANGE_STATUS',
|
||||
'CHAMA_AI_ACTION',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
required: ['enabled'],
|
||||
...isNotEmpty('enabled'),
|
||||
};
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Logger } from '../../config/logger.config';
|
||||
import { InstanceDto } from '../dto/instance.dto';
|
||||
import { Logger } from '../../../../config/logger.config';
|
||||
import { InstanceDto } from '../../../dto/instance.dto';
|
||||
import { SqsDto } from '../dto/sqs.dto';
|
||||
import { SqsService } from '../services/sqs.service';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { SQS } from 'aws-sdk';
|
||||
import { SQS } from '@aws-sdk/client-sqs';
|
||||
|
||||
import { configService, Sqs } from '../config/env.config';
|
||||
import { Logger } from '../config/logger.config';
|
||||
import { configService, Sqs } from '../../../../config/env.config';
|
||||
import { Logger } from '../../../../config/logger.config';
|
||||
|
||||
const logger = new Logger('SQS');
|
||||
|
||||
@@ -12,8 +12,11 @@ export const initSQS = () => {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
const awsConfig = configService.get<Sqs>('SQS');
|
||||
sqs = new SQS({
|
||||
accessKeyId: awsConfig.ACCESS_KEY_ID,
|
||||
secretAccessKey: awsConfig.SECRET_ACCESS_KEY,
|
||||
credentials: {
|
||||
accessKeyId: awsConfig.ACCESS_KEY_ID,
|
||||
secretAccessKey: awsConfig.SECRET_ACCESS_KEY,
|
||||
},
|
||||
|
||||
region: awsConfig.REGION,
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Schema } from 'mongoose';
|
||||
|
||||
import { dbserver } from '../../libs/db.connect';
|
||||
import { dbserver } from '../../../../libs/db.connect';
|
||||
|
||||
export class SqsRaw {
|
||||
_id?: string;
|
||||
@@ -1,10 +1,10 @@
|
||||
import { readFileSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
|
||||
import { ConfigService } from '../../config/env.config';
|
||||
import { Logger } from '../../config/logger.config';
|
||||
import { IInsert, Repository } from '../abstract/abstract.repository';
|
||||
import { ISqsModel, SqsRaw } from '../models';
|
||||
import { ConfigService } from '../../../../config/env.config';
|
||||
import { Logger } from '../../../../config/logger.config';
|
||||
import { IInsert, Repository } from '../../../abstract/abstract.repository';
|
||||
import { ISqsModel, SqsRaw } from '../../../models';
|
||||
|
||||
export class SqsRepository extends Repository {
|
||||
constructor(private readonly sqsModel: ISqsModel, private readonly configService: ConfigService) {
|
||||
@@ -1,12 +1,12 @@
|
||||
import { RequestHandler, Router } from 'express';
|
||||
|
||||
import { Logger } from '../../config/logger.config';
|
||||
import { instanceNameSchema, sqsSchema } from '../../validate/validate.schema';
|
||||
import { RouterBroker } from '../abstract/abstract.router';
|
||||
import { InstanceDto } from '../dto/instance.dto';
|
||||
import { Logger } from '../../../../config/logger.config';
|
||||
import { instanceNameSchema, sqsSchema } from '../../../../validate/validate.schema';
|
||||
import { RouterBroker } from '../../../abstract/abstract.router';
|
||||
import { InstanceDto } from '../../../dto/instance.dto';
|
||||
import { HttpStatus } from '../../../routes/index.router';
|
||||
import { sqsController } from '../../../server.module';
|
||||
import { SqsDto } from '../dto/sqs.dto';
|
||||
import { sqsController } from '../whatsapp.module';
|
||||
import { HttpStatus } from './index.router';
|
||||
|
||||
const logger = new Logger('SqsRouter');
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Logger } from '../../config/logger.config';
|
||||
import { initQueues } from '../../libs/sqs.server';
|
||||
import { InstanceDto } from '../dto/instance.dto';
|
||||
import { Logger } from '../../../../config/logger.config';
|
||||
import { InstanceDto } from '../../../dto/instance.dto';
|
||||
import { SqsRaw } from '../../../models';
|
||||
import { WAMonitoringService } from '../../../services/monitor.service';
|
||||
import { SqsDto } from '../dto/sqs.dto';
|
||||
import { SqsRaw } from '../models';
|
||||
import { WAMonitoringService } from './monitor.service';
|
||||
import { initQueues } from '../libs/sqs.server';
|
||||
|
||||
export class SqsService {
|
||||
constructor(private readonly waMonitor: WAMonitoringService) {}
|
||||
66
src/api/integrations/sqs/validate/sqs.schema.ts
Normal file
66
src/api/integrations/sqs/validate/sqs.schema.ts
Normal file
@@ -0,0 +1,66 @@
|
||||
import { JSONSchema7 } from 'json-schema';
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
const isNotEmpty = (...propertyNames: string[]): JSONSchema7 => {
|
||||
const properties = {};
|
||||
propertyNames.forEach(
|
||||
(property) =>
|
||||
(properties[property] = {
|
||||
minLength: 1,
|
||||
description: `The "${property}" cannot be empty`,
|
||||
}),
|
||||
);
|
||||
return {
|
||||
if: {
|
||||
propertyNames: {
|
||||
enum: [...propertyNames],
|
||||
},
|
||||
},
|
||||
then: { properties },
|
||||
};
|
||||
};
|
||||
|
||||
export const sqsSchema: JSONSchema7 = {
|
||||
$id: v4(),
|
||||
type: 'object',
|
||||
properties: {
|
||||
enabled: { type: 'boolean', enum: [true, false] },
|
||||
events: {
|
||||
type: 'array',
|
||||
minItems: 0,
|
||||
items: {
|
||||
type: 'string',
|
||||
enum: [
|
||||
'APPLICATION_STARTUP',
|
||||
'QRCODE_UPDATED',
|
||||
'MESSAGES_SET',
|
||||
'MESSAGES_UPSERT',
|
||||
'MESSAGES_UPDATE',
|
||||
'MESSAGES_DELETE',
|
||||
'SEND_MESSAGE',
|
||||
'CONTACTS_SET',
|
||||
'CONTACTS_UPSERT',
|
||||
'CONTACTS_UPDATE',
|
||||
'PRESENCE_UPDATE',
|
||||
'CHATS_SET',
|
||||
'CHATS_UPSERT',
|
||||
'CHATS_UPDATE',
|
||||
'CHATS_DELETE',
|
||||
'GROUPS_UPSERT',
|
||||
'GROUP_UPDATE',
|
||||
'GROUP_PARTICIPANTS_UPDATE',
|
||||
'CONNECTION_UPDATE',
|
||||
'LABELS_EDIT',
|
||||
'LABELS_ASSOCIATION',
|
||||
'CALL',
|
||||
'NEW_JWT_TOKEN',
|
||||
'TYPEBOT_START',
|
||||
'TYPEBOT_CHANGE_STATUS',
|
||||
'CHAMA_AI_ACTION',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
required: ['enabled'],
|
||||
...isNotEmpty('enabled'),
|
||||
};
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Logger } from '../../config/logger.config';
|
||||
import { InstanceDto } from '../dto/instance.dto';
|
||||
import { Logger } from '../../../../config/logger.config';
|
||||
import { InstanceDto } from '../../../dto/instance.dto';
|
||||
import { TypebotDto } from '../dto/typebot.dto';
|
||||
import { TypebotService } from '../services/typebot.service';
|
||||
|
||||
@@ -10,6 +10,7 @@ export class Session {
|
||||
export class PrefilledVariables {
|
||||
remoteJid?: string;
|
||||
pushName?: string;
|
||||
messageType?: string;
|
||||
additionalData?: { [key: string]: any };
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Schema } from 'mongoose';
|
||||
|
||||
import { dbserver } from '../../libs/db.connect';
|
||||
import { dbserver } from '../../../../libs/db.connect';
|
||||
|
||||
class Session {
|
||||
remoteJid?: string;
|
||||
@@ -1,10 +1,10 @@
|
||||
import { readFileSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
|
||||
import { ConfigService } from '../../config/env.config';
|
||||
import { Logger } from '../../config/logger.config';
|
||||
import { IInsert, Repository } from '../abstract/abstract.repository';
|
||||
import { ITypebotModel, TypebotRaw } from '../models';
|
||||
import { ConfigService } from '../../../../config/env.config';
|
||||
import { Logger } from '../../../../config/logger.config';
|
||||
import { IInsert, Repository } from '../../../abstract/abstract.repository';
|
||||
import { ITypebotModel, TypebotRaw } from '../../../models';
|
||||
|
||||
export class TypebotRepository extends Repository {
|
||||
constructor(private readonly typebotModel: ITypebotModel, private readonly configService: ConfigService) {
|
||||
@@ -1,17 +1,17 @@
|
||||
import { RequestHandler, Router } from 'express';
|
||||
|
||||
import { Logger } from '../../config/logger.config';
|
||||
import { Logger } from '../../../../config/logger.config';
|
||||
import {
|
||||
instanceNameSchema,
|
||||
typebotSchema,
|
||||
typebotStartSchema,
|
||||
typebotStatusSchema,
|
||||
} from '../../validate/validate.schema';
|
||||
import { RouterBroker } from '../abstract/abstract.router';
|
||||
import { InstanceDto } from '../dto/instance.dto';
|
||||
} from '../../../../validate/validate.schema';
|
||||
import { RouterBroker } from '../../../abstract/abstract.router';
|
||||
import { InstanceDto } from '../../../dto/instance.dto';
|
||||
import { HttpStatus } from '../../../routes/index.router';
|
||||
import { typebotController } from '../../../server.module';
|
||||
import { TypebotDto } from '../dto/typebot.dto';
|
||||
import { typebotController } from '../whatsapp.module';
|
||||
import { HttpStatus } from './index.router';
|
||||
|
||||
const logger = new Logger('TypebotRouter');
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import axios from 'axios';
|
||||
import EventEmitter2 from 'eventemitter2';
|
||||
|
||||
import { ConfigService, Typebot } from '../../config/env.config';
|
||||
import { Logger } from '../../config/logger.config';
|
||||
import { InstanceDto } from '../dto/instance.dto';
|
||||
import { ConfigService, Typebot } from '../../../../config/env.config';
|
||||
import { Logger } from '../../../../config/logger.config';
|
||||
import { InstanceDto } from '../../../dto/instance.dto';
|
||||
import { MessageRaw } from '../../../models';
|
||||
import { WAMonitoringService } from '../../../services/monitor.service';
|
||||
import { Events } from '../../../types/wa.types';
|
||||
import { Session, TypebotDto } from '../dto/typebot.dto';
|
||||
import { MessageRaw } from '../models';
|
||||
import { Events } from '../types/wa.types';
|
||||
import { WAMonitoringService } from './monitor.service';
|
||||
|
||||
export class TypebotService {
|
||||
constructor(
|
||||
@@ -270,16 +270,27 @@ export class TypebotService {
|
||||
|
||||
private getTypeMessage(msg: any) {
|
||||
this.logger.verbose('get type message');
|
||||
|
||||
const types = {
|
||||
conversation: msg.conversation,
|
||||
extendedTextMessage: msg.extendedTextMessage?.text,
|
||||
audioMessage: msg.audioMessage?.url,
|
||||
imageMessage: msg.imageMessage?.url,
|
||||
videoMessage: msg.videoMessage?.url,
|
||||
documentMessage: msg.documentMessage?.fileName,
|
||||
contactMessage: msg.contactMessage?.displayName,
|
||||
locationMessage: msg.locationMessage?.degreesLatitude,
|
||||
viewOnceMessageV2:
|
||||
msg.viewOnceMessageV2?.message?.imageMessage?.url ||
|
||||
msg.viewOnceMessageV2?.message?.videoMessage?.url ||
|
||||
msg.viewOnceMessageV2?.message?.audioMessage?.url,
|
||||
listResponseMessage: msg.listResponseMessage?.singleSelectReply?.selectedRowId,
|
||||
responseRowId: msg.listResponseMessage?.singleSelectReply?.selectedRowId,
|
||||
};
|
||||
|
||||
this.logger.verbose('type message: ' + types);
|
||||
const messageType = Object.keys(types).find((key) => types[key] !== undefined) || 'unknown';
|
||||
|
||||
return types;
|
||||
this.logger.verbose('Type message: ' + JSON.stringify(types));
|
||||
return { ...types, messageType };
|
||||
}
|
||||
|
||||
private getMessageContent(types: any) {
|
||||
@@ -305,6 +316,101 @@ export class TypebotService {
|
||||
return messageContent;
|
||||
}
|
||||
|
||||
private getAudioMessageContent(msg: any) {
|
||||
this.logger.verbose('get audio message content');
|
||||
|
||||
const types = this.getTypeMessage(msg);
|
||||
|
||||
const audioContent = types.audioMessage;
|
||||
|
||||
this.logger.verbose('audio message URL: ' + audioContent);
|
||||
|
||||
return audioContent;
|
||||
}
|
||||
|
||||
private getImageMessageContent(msg: any) {
|
||||
this.logger.verbose('get image message content');
|
||||
|
||||
const types = this.getTypeMessage(msg);
|
||||
|
||||
const imageContent = types.imageMessage;
|
||||
|
||||
this.logger.verbose('image message URL: ' + imageContent);
|
||||
|
||||
return imageContent;
|
||||
}
|
||||
|
||||
private getVideoMessageContent(msg: any) {
|
||||
this.logger.verbose('get video message content');
|
||||
|
||||
const types = this.getTypeMessage(msg);
|
||||
|
||||
const videoContent = types.videoMessage;
|
||||
|
||||
this.logger.verbose('video message URL: ' + videoContent);
|
||||
|
||||
return videoContent;
|
||||
}
|
||||
|
||||
private getDocumentMessageContent(msg: any) {
|
||||
this.logger.verbose('get document message content');
|
||||
|
||||
const types = this.getTypeMessage(msg);
|
||||
|
||||
const documentContent = types.documentMessage;
|
||||
|
||||
this.logger.verbose('document message fileName: ' + documentContent);
|
||||
|
||||
return documentContent;
|
||||
}
|
||||
|
||||
private getContactMessageContent(msg: any) {
|
||||
this.logger.verbose('get contact message content');
|
||||
|
||||
const types = this.getTypeMessage(msg);
|
||||
|
||||
const contactContent = types.contactMessage;
|
||||
|
||||
this.logger.verbose('contact message displayName: ' + contactContent);
|
||||
|
||||
return contactContent;
|
||||
}
|
||||
|
||||
private getLocationMessageContent(msg: any) {
|
||||
this.logger.verbose('get location message content');
|
||||
|
||||
const types = this.getTypeMessage(msg);
|
||||
|
||||
const locationContent = types.locationMessage;
|
||||
|
||||
this.logger.verbose('location message degreesLatitude: ' + locationContent);
|
||||
|
||||
return locationContent;
|
||||
}
|
||||
|
||||
private getViewOnceMessageV2Content(msg: any) {
|
||||
this.logger.verbose('get viewOnceMessageV2 content');
|
||||
|
||||
const types = this.getTypeMessage(msg);
|
||||
|
||||
const viewOnceContent = types.viewOnceMessageV2;
|
||||
|
||||
this.logger.verbose('viewOnceMessageV2 URL: ' + viewOnceContent);
|
||||
|
||||
return viewOnceContent;
|
||||
}
|
||||
|
||||
private getListResponseMessageContent(msg: any) {
|
||||
this.logger.verbose('get listResponseMessage content');
|
||||
|
||||
const types = this.getTypeMessage(msg);
|
||||
|
||||
const listResponseContent = types.listResponseMessage || types.responseRowId;
|
||||
|
||||
this.logger.verbose('listResponseMessage selectedRowId: ' + listResponseContent);
|
||||
|
||||
return listResponseContent;
|
||||
}
|
||||
public async createNewSession(instance: InstanceDto, data: any) {
|
||||
if (data.remoteJid === 'status@broadcast') return;
|
||||
const id = Math.floor(Math.random() * 10000000000).toString();
|
||||
@@ -413,18 +519,36 @@ export class TypebotService {
|
||||
text += element.text;
|
||||
}
|
||||
|
||||
if (
|
||||
element.children &&
|
||||
(element.type === 'p' ||
|
||||
element.type === 'a' ||
|
||||
element.type === 'inline-variable' ||
|
||||
element.type === 'variable')
|
||||
) {
|
||||
if (element.children && element.type !== 'a') {
|
||||
for (const child of element.children) {
|
||||
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 = '';
|
||||
|
||||
if (element.bold) {
|
||||
@@ -462,6 +586,8 @@ export class TypebotService {
|
||||
|
||||
formattedText = formattedText.replace(/\*\*/g, '').replace(/__/, '').replace(/~~/, '').replace(/\n$/, '');
|
||||
|
||||
formattedText = formattedText.replace(/\n$/, '');
|
||||
|
||||
await instance.textMessage({
|
||||
number: remoteJid.split('@')[0],
|
||||
options: {
|
||||
@@ -565,6 +691,7 @@ export class TypebotService {
|
||||
const delay_message = findTypebot.delay_message;
|
||||
const unknown_message = findTypebot.unknown_message;
|
||||
const listening_from_me = findTypebot.listening_from_me;
|
||||
const messageType = this.getTypeMessage(msg.message).messageType;
|
||||
|
||||
const session = sessions.find((session) => session.remoteJid === remoteJid);
|
||||
|
||||
@@ -687,6 +814,9 @@ export class TypebotService {
|
||||
sessions: sessions,
|
||||
remoteJid: remoteJid,
|
||||
pushName: msg.pushName,
|
||||
prefilledVariables: {
|
||||
messageType: messageType,
|
||||
},
|
||||
});
|
||||
|
||||
await this.sendWAMessage(instance, remoteJid, data.messages, data.input, data.clientSideActions);
|
||||
60
src/api/integrations/typebot/validate/typebot.schema.ts
Normal file
60
src/api/integrations/typebot/validate/typebot.schema.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
import { JSONSchema7 } from 'json-schema';
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
const isNotEmpty = (...propertyNames: string[]): JSONSchema7 => {
|
||||
const properties = {};
|
||||
propertyNames.forEach(
|
||||
(property) =>
|
||||
(properties[property] = {
|
||||
minLength: 1,
|
||||
description: `The "${property}" cannot be empty`,
|
||||
}),
|
||||
);
|
||||
return {
|
||||
if: {
|
||||
propertyNames: {
|
||||
enum: [...propertyNames],
|
||||
},
|
||||
},
|
||||
then: { properties },
|
||||
};
|
||||
};
|
||||
|
||||
export const typebotSchema: JSONSchema7 = {
|
||||
$id: v4(),
|
||||
type: 'object',
|
||||
properties: {
|
||||
enabled: { type: 'boolean', enum: [true, false] },
|
||||
url: { type: 'string' },
|
||||
typebot: { type: 'string' },
|
||||
expire: { type: 'integer' },
|
||||
delay_message: { type: 'integer' },
|
||||
unknown_message: { type: 'string' },
|
||||
listening_from_me: { type: 'boolean', enum: [true, false] },
|
||||
},
|
||||
required: ['enabled', 'url', 'typebot', 'expire', 'delay_message', 'unknown_message', 'listening_from_me'],
|
||||
...isNotEmpty('enabled', 'url', 'typebot', 'expire', 'delay_message', 'unknown_message', 'listening_from_me'),
|
||||
};
|
||||
|
||||
export const typebotStatusSchema: JSONSchema7 = {
|
||||
$id: v4(),
|
||||
type: 'object',
|
||||
properties: {
|
||||
remoteJid: { type: 'string' },
|
||||
status: { type: 'string', enum: ['opened', 'closed', 'paused'] },
|
||||
},
|
||||
required: ['remoteJid', 'status'],
|
||||
...isNotEmpty('remoteJid', 'status'),
|
||||
};
|
||||
|
||||
export const typebotStartSchema: JSONSchema7 = {
|
||||
$id: v4(),
|
||||
type: 'object',
|
||||
properties: {
|
||||
remoteJid: { type: 'string' },
|
||||
url: { type: 'string' },
|
||||
typebot: { type: 'string' },
|
||||
},
|
||||
required: ['remoteJid', 'url', 'typebot'],
|
||||
...isNotEmpty('remoteJid', 'url', 'typebot'),
|
||||
};
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Logger } from '../../config/logger.config';
|
||||
import { InstanceDto } from '../dto/instance.dto';
|
||||
import { Logger } from '../../../../config/logger.config';
|
||||
import { InstanceDto } from '../../../dto/instance.dto';
|
||||
import { WebsocketDto } from '../dto/websocket.dto';
|
||||
import { WebsocketService } from '../services/websocket.service';
|
||||
|
||||
@@ -1,20 +1,24 @@
|
||||
import { Server } from 'http';
|
||||
import { Server as SocketIO } from 'socket.io';
|
||||
|
||||
import { configService, Cors, Websocket } from '../config/env.config';
|
||||
import { Logger } from '../config/logger.config';
|
||||
import { configService, Cors, Websocket } from '../../../../config/env.config';
|
||||
import { Logger } from '../../../../config/logger.config';
|
||||
|
||||
const logger = new Logger('Socket');
|
||||
|
||||
let io: SocketIO;
|
||||
|
||||
const cors = configService.get<Cors>('CORS').ORIGIN;
|
||||
const origin = configService.get<Cors>('CORS').ORIGIN;
|
||||
const methods = configService.get<Cors>('CORS').METHODS;
|
||||
const credentials = configService.get<Cors>('CORS').CREDENTIALS;
|
||||
|
||||
export const initIO = (httpServer: Server) => {
|
||||
if (configService.get<Websocket>('WEBSOCKET')?.ENABLED) {
|
||||
io = new SocketIO(httpServer, {
|
||||
cors: {
|
||||
origin: cors,
|
||||
origin,
|
||||
methods,
|
||||
credentials,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Schema } from 'mongoose';
|
||||
|
||||
import { dbserver } from '../../libs/db.connect';
|
||||
import { dbserver } from '../../../../libs/db.connect';
|
||||
|
||||
export class WebsocketRaw {
|
||||
_id?: string;
|
||||
@@ -1,10 +1,10 @@
|
||||
import { readFileSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
|
||||
import { ConfigService } from '../../config/env.config';
|
||||
import { Logger } from '../../config/logger.config';
|
||||
import { IInsert, Repository } from '../abstract/abstract.repository';
|
||||
import { IWebsocketModel, WebsocketRaw } from '../models';
|
||||
import { ConfigService } from '../../../../config/env.config';
|
||||
import { Logger } from '../../../../config/logger.config';
|
||||
import { IInsert, Repository } from '../../../abstract/abstract.repository';
|
||||
import { IWebsocketModel, WebsocketRaw } from '../../../models';
|
||||
|
||||
export class WebsocketRepository extends Repository {
|
||||
constructor(private readonly websocketModel: IWebsocketModel, private readonly configService: ConfigService) {
|
||||
@@ -1,12 +1,12 @@
|
||||
import { RequestHandler, Router } from 'express';
|
||||
|
||||
import { Logger } from '../../config/logger.config';
|
||||
import { instanceNameSchema, websocketSchema } from '../../validate/validate.schema';
|
||||
import { RouterBroker } from '../abstract/abstract.router';
|
||||
import { InstanceDto } from '../dto/instance.dto';
|
||||
import { Logger } from '../../../../config/logger.config';
|
||||
import { instanceNameSchema, websocketSchema } from '../../../../validate/validate.schema';
|
||||
import { RouterBroker } from '../../../abstract/abstract.router';
|
||||
import { InstanceDto } from '../../../dto/instance.dto';
|
||||
import { HttpStatus } from '../../../routes/index.router';
|
||||
import { websocketController } from '../../../server.module';
|
||||
import { WebsocketDto } from '../dto/websocket.dto';
|
||||
import { websocketController } from '../whatsapp.module';
|
||||
import { HttpStatus } from './index.router';
|
||||
|
||||
const logger = new Logger('WebsocketRouter');
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Logger } from '../../config/logger.config';
|
||||
import { InstanceDto } from '../dto/instance.dto';
|
||||
import { Logger } from '../../../../config/logger.config';
|
||||
import { InstanceDto } from '../../../dto/instance.dto';
|
||||
import { WebsocketRaw } from '../../../models';
|
||||
import { WAMonitoringService } from '../../../services/monitor.service';
|
||||
import { WebsocketDto } from '../dto/websocket.dto';
|
||||
import { WebsocketRaw } from '../models';
|
||||
import { WAMonitoringService } from './monitor.service';
|
||||
|
||||
export class WebsocketService {
|
||||
constructor(private readonly waMonitor: WAMonitoringService) {}
|
||||
66
src/api/integrations/websocket/validate/websocket.schema.ts
Normal file
66
src/api/integrations/websocket/validate/websocket.schema.ts
Normal file
@@ -0,0 +1,66 @@
|
||||
import { JSONSchema7 } from 'json-schema';
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
const isNotEmpty = (...propertyNames: string[]): JSONSchema7 => {
|
||||
const properties = {};
|
||||
propertyNames.forEach(
|
||||
(property) =>
|
||||
(properties[property] = {
|
||||
minLength: 1,
|
||||
description: `The "${property}" cannot be empty`,
|
||||
}),
|
||||
);
|
||||
return {
|
||||
if: {
|
||||
propertyNames: {
|
||||
enum: [...propertyNames],
|
||||
},
|
||||
},
|
||||
then: { properties },
|
||||
};
|
||||
};
|
||||
|
||||
export const websocketSchema: JSONSchema7 = {
|
||||
$id: v4(),
|
||||
type: 'object',
|
||||
properties: {
|
||||
enabled: { type: 'boolean', enum: [true, false] },
|
||||
events: {
|
||||
type: 'array',
|
||||
minItems: 0,
|
||||
items: {
|
||||
type: 'string',
|
||||
enum: [
|
||||
'APPLICATION_STARTUP',
|
||||
'QRCODE_UPDATED',
|
||||
'MESSAGES_SET',
|
||||
'MESSAGES_UPSERT',
|
||||
'MESSAGES_UPDATE',
|
||||
'MESSAGES_DELETE',
|
||||
'SEND_MESSAGE',
|
||||
'CONTACTS_SET',
|
||||
'CONTACTS_UPSERT',
|
||||
'CONTACTS_UPDATE',
|
||||
'PRESENCE_UPDATE',
|
||||
'CHATS_SET',
|
||||
'CHATS_UPSERT',
|
||||
'CHATS_UPDATE',
|
||||
'CHATS_DELETE',
|
||||
'GROUPS_UPSERT',
|
||||
'GROUP_UPDATE',
|
||||
'GROUP_PARTICIPANTS_UPDATE',
|
||||
'CONNECTION_UPDATE',
|
||||
'LABELS_EDIT',
|
||||
'LABELS_ASSOCIATION',
|
||||
'CALL',
|
||||
'NEW_JWT_TOKEN',
|
||||
'TYPEBOT_START',
|
||||
'TYPEBOT_CHANGE_STATUS',
|
||||
'CHAMA_AI_ACTION',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
required: ['enabled'],
|
||||
...isNotEmpty('enabled'),
|
||||
};
|
||||
15
src/api/models/index.ts
Normal file
15
src/api/models/index.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
export * from '../integrations/chamaai/models/chamaai.model';
|
||||
export * from '../integrations/chatwoot/models/chatwoot.model';
|
||||
export * from '../integrations/rabbitmq/models/rabbitmq.model';
|
||||
export * from '../integrations/sqs/models/sqs.model';
|
||||
export * from '../integrations/typebot/models/typebot.model';
|
||||
export * from '../integrations/websocket/models/websocket.model';
|
||||
export * from './auth.model';
|
||||
export * from './chat.model';
|
||||
export * from './contact.model';
|
||||
export * from './integration.model';
|
||||
export * from './label.model';
|
||||
export * from './message.model';
|
||||
export * from './proxy.model';
|
||||
export * from './settings.model';
|
||||
export * from './webhook.model';
|
||||
@@ -9,12 +9,12 @@ export class IntegrationRaw {
|
||||
token?: string;
|
||||
}
|
||||
|
||||
const sqsSchema = new Schema<IntegrationRaw>({
|
||||
const integrationSchema = new Schema<IntegrationRaw>({
|
||||
_id: { type: String, _id: true },
|
||||
integration: { type: String, required: true },
|
||||
number: { type: String, required: true },
|
||||
token: { type: String, required: true },
|
||||
});
|
||||
|
||||
export const IntegrationModel = dbserver?.model(IntegrationRaw.name, sqsSchema, 'integration');
|
||||
export const IntegrationModel = dbserver?.model(IntegrationRaw.name, integrationSchema, 'integration');
|
||||
export type IntegrationModel = typeof IntegrationModel;
|
||||
@@ -1,3 +1,4 @@
|
||||
import Long from 'long';
|
||||
import { Schema } from 'mongoose';
|
||||
|
||||
import { dbserver } from '../../libs/db.connect';
|
||||
@@ -23,15 +24,16 @@ export class MessageRaw {
|
||||
key?: Key;
|
||||
pushName?: string;
|
||||
participant?: string;
|
||||
message?: object;
|
||||
message?: any;
|
||||
messageType?: string;
|
||||
messageTimestamp?: number | Long.Long;
|
||||
messageTimestamp?: number | Long;
|
||||
owner: string;
|
||||
source?: 'android' | 'web' | 'ios' | 'unknown' | 'desktop';
|
||||
source_id?: string;
|
||||
source_reply_id?: string;
|
||||
chatwoot?: ChatwootMessage;
|
||||
contextInfo?: any;
|
||||
status?: wa.StatusMessage | any;
|
||||
}
|
||||
|
||||
type MessageRawBoolean<T> = {
|
||||
@@ -11,6 +11,7 @@ export class SettingsRaw {
|
||||
read_messages?: boolean;
|
||||
read_status?: boolean;
|
||||
sync_full_history?: boolean;
|
||||
wavoipToken?: string;
|
||||
}
|
||||
|
||||
const settingsSchema = new Schema<SettingsRaw>({
|
||||
@@ -22,6 +23,7 @@ const settingsSchema = new Schema<SettingsRaw>({
|
||||
read_messages: { type: Boolean, required: true },
|
||||
read_status: { type: Boolean, required: true },
|
||||
sync_full_history: { type: Boolean, required: true },
|
||||
wavoipToken: { type: String, required: true },
|
||||
});
|
||||
|
||||
export const SettingsModel = dbserver?.model(SettingsRaw.name, settingsSchema, 'settings');
|
||||
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[]> {
|
||||
try {
|
||||
if (this.dbSettings.ENABLED) {
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user