Commit Graph

2623 Commits

Author SHA1 Message Date
Jeferson Ramos
067f0999b5 lint 2025-11-19 14:07:23 -03:00
Jeferson Ramos
179af3f41c lint 2025-11-19 14:02:52 -03:00
Jeferson Ramos
31a6f2d92e ; 2025-11-19 14:00:17 -03:00
Jeferson Ramos
dc72f01625 Merge remote-tracking branch 'upstream/main' into bugfix/media-upload-failed-on-all-hosts 2025-11-19 13:34:47 -03:00
Jeferson Ramos
3b139078c3 Removendo uso do undici com proxy socks 2025-11-19 13:34:33 -03:00
Jonatas
f2c2a6a64a refactor: improve formatting and consistency in makeProxyAgent functions 2025-11-18 23:58:18 -03:00
Jonatas
e5a249109c feat: add quotedMessage to payload in sendMessageToBot on N8N 2025-11-18 23:52:36 -03:00
Davidson Gomes
73fb376602
Merge pull request #2219 from victoreduardo/evo/main
Some checks failed
Security Scan / CodeQL Analysis (javascript) (push) Has been cancelled
Security Scan / Dependency Review (push) Has been cancelled
Check Code Quality / check-lint-and-build (push) Has been cancelled
Build Docker image / Build and Deploy (push) Has been cancelled
Fix: Chatwoot service fails when processing read message
2025-11-13 14:03:09 -03:00
Victor Eduardo
27633aad53 feature: handle with interactive button message for pix 2025-11-13 09:47:53 -03:00
Victor Eduardo
06543e89e5 fix: await chatwootRequest in update_last_seen method for proper asynchronous handling 2025-11-12 22:47:05 -03:00
Davidson Gomes
90640b7cee
Merge pull request #2203 from RaFaeL-Cunha/patch-1
Some checks failed
Check Code Quality / check-lint-and-build (push) Has been cancelled
Build Docker image / Build and Deploy (push) Has been cancelled
Security Scan / CodeQL Analysis (javascript) (push) Has been cancelled
Security Scan / Dependency Review (push) Has been cancelled
fix(chatwoot): corrige erro de duplicação na importação de contatos
2025-11-11 08:45:00 -03:00
Rafael Freire Cunha
da8774caa2
fix(chatwoot): corrige erro de duplicação na importação de contatos
Resolve o erro 'ON CONFLICT DO UPDATE command cannot affect row a second time' que ocorria ao importar histórico de contatos duplicados.

A correção remove a tentativa de atualizar o campo 'identifier' no ON CONFLICT, já que este campo faz parte da constraint de conflito e não pode ser atualizado.

Erro original:
- identifier = EXCLUDED.identifier

Correção:
- updated_at = NOW()

Isso permite que contatos duplicados sejam atualizados corretamente sem causar erro.
2025-11-09 14:56:53 -04:00
Davidson Gomes
4ae3139163 chore(changelog): update to version 2.3.7 with new features and fixes
Some checks failed
Check Code Quality / check-lint-and-build (push) Has been cancelled
Build Docker image / Build and Deploy (push) Has been cancelled
Security Scan / CodeQL Analysis (javascript) (push) Has been cancelled
Security Scan / Dependency Review (push) Has been cancelled
- Added update and delete endpoints for WhatsApp Business Meta templates.
- Fixed issues with incoming message events and authentication states after reconnection.
- Resolved unique constraint errors in OnWhatsapp cache and optimized database writes.
- Improved proxy integration for media uploads and fixed handling of base64, filename, and caption in the WhatsApp Business API.
- Enhanced chat service reliability and contact filtering capabilities.
- Made multiple integration improvements between Chatwoot and Baileys.
- Refactored code for better quality and consistency.
2025-11-07 14:45:38 -03:00
Davidson Gomes
f4043a9141 fix(whatsapp-cache): improve error logging in save function
Updated the error handling in the saveOnWhatsappCache function to log the error message separately, improving clarity on issues encountered during item processing.
2025-11-07 14:41:40 -03:00
Davidson Gomes
139ad9b3cb
Merge pull request #2186 from muriloleal13/fix/baileys-message-processor-reconnection
fix(baileys): resolve incoming message events not working after reconnection
2025-11-07 14:39:26 -03:00
Davidson Gomes
fca39a2b34
Merge pull request #2191 from JefersonRamos/bugfix/waiting-for-message
Durante o processo de logout de uma instância, as chaves associadas a…
2025-11-07 14:38:36 -03:00
Davidson Gomes
1e3a23588e
Merge pull request #2163 from ricaelchiquetti/feat/update_delete_meta_templates
Feat/update and delete meta templates
2025-11-07 14:36:14 -03:00
Davidson Gomes
27be03ea95
Merge pull request #2162 from moothz/fix/saveOnWhatsappCache-remoteJid-failed-constraint
fix: Erro ao enviar mensagem para grupos (remoteJid failed constraint)
2025-11-07 14:35:23 -03:00
Davidson Gomes
9b73252f35
Merge branch 'develop' into fix/saveOnWhatsappCache-remoteJid-failed-constraint 2025-11-07 14:33:58 -03:00
Davidson Gomes
71322cd8f6
Merge pull request #2161 from ricaelchiquetti/main
feat(whatsapp): corrigir Business (base64/filename/caption), remoteJid
2025-11-07 14:32:37 -03:00
Davidson Gomes
263854db47
Merge pull request #2160 from moothz/fix/fetchChats-cleanMessageData-errors
fix: fetchChats e chat - Painel de mensagens no Manager
2025-11-07 14:27:25 -03:00
Davidson Gomes
400b6291a2
Merge pull request #2158 from KokeroO/develop
fix: Integration Chatwoot and Baileys services
2025-11-07 14:26:32 -03:00
Jeferson Ramos
feff038446 lint ajustes 2025-11-05 16:30:32 -03:00
Jeferson Ramos
4d2a189905 lint ajustes 2025-11-05 16:29:09 -03:00
Jeferson Ramos
48625a739c Merge branch 'main' into bugfix/waiting-for-message 2025-11-05 16:27:22 -03:00
Jeferson Ramos
b6620d2bd6 responde in log 2025-11-05 16:26:55 -03:00
Jeferson Ramos
45e461e757 lint 2025-11-05 16:03:09 -03:00
Jeferson Ramos
be5760905e Durante o processo de logout de uma instância, as chaves associadas ao estado criptográfico não estavam sendo removidas corretamente do Redis.
Dessa forma, quando uma nova conexão era estabelecida reutilizando o mesmo instanceName, o Baileys carregava chaves antigas e inválidas, incompatíveis com o novo conjunto de credenciais (creds) gerado na reconexão.

Essa inconsistência gerava o seguinte sintoma prático:

A instância autenticava com sucesso;

Contudo, ao tentar enviar mensagens, entrava em estado de bloqueio, exibindo o status “aguardando mensagem” indefinidamente.
2025-11-05 15:39:21 -03:00
Murilo Leal
92626fa559 fix(baileys): resolve incoming message events not working after reconnection
- Add cleanup logic in mount() to prevent memory leaks from multiple subscriptions

- Recreate messageSubject if it was completed during logout

- Remount messageProcessor in connectToWhatsapp() to ensure subscription is active after reconnection

This fixes the issue where incoming message events stop working after logout and reconnect, while outgoing message events continue to work normally.

The root cause was that onDestroy() calls complete() on the RxJS Subject, making it permanently closed. When reconnecting, the Subject would silently ignore all new messages.

The fix ensures that:

1. Old subscriptions are properly cleaned up before creating new ones

2. If the Subject is closed, a new one is created automatically

3. The messageProcessor is remounted on every connection to ensure active subscription
2025-11-04 13:49:38 -03:00
ricael
1aaad541ad chore(dto): remove unused template edit/delete DTOs 2025-10-30 16:59:30 -03:00
ricael
3b0432dd9f refactor(utils): lint 2025-10-30 16:36:01 -03:00
ricael
a95c843e77 feat(template): add edit/delete endpoints, DTOs and validation" 2025-10-30 16:28:53 -03:00
moothz
8d1151d0a0
fix: lint
Descartei as mudanças nos arquivos que não me pertencem, dá uma folga aí, botinho
2025-10-30 16:18:33 -03:00
moothz
a1393b679c fix(OnWhatsappCache): Prevent unique constraint errors and optimize DB writes
Refactors the cache-saving logic to prevent `Unique constraint failed` errors. This issue occurs when an item's `remoteJid` is not yet included in the `jidOptions` of the existing record.

The database query now uses an `OR` condition to find a matching record by either `jidOptions` (using `contains`) or by the `remoteJid` itself in a single query.

Additionally, this commit introduces several performance optimizations:

1.  **Skip Unnecessary Updates**: The function now performs a deep comparison between the new payload and the `existingRecord`. An `update` operation is only executed if the data has actually changed, reducing unnecessary database writes.
2.  **Parallel Processing**: The sequential `for...of` loop has been replaced with `Promise.allSettled`. This allows all items in the `data` array to be processed concurrently, significantly speeding up execution for batch inputs.
3.  **Data Consistency**: The JIDs in `jidOptions` are now sorted alphabetically before being joined into a string. This ensures that the change-detection logic is accurate, regardless of the order in which JIDs were discovered.
4.  **Refactor**: Simplified JID unification logic using a `Set` and introduced a `normalizeJid` helper function for cleaner code.

TODO: Investigate the root cause of why `remoteJid` is sometimes not present in `jidOptions` upon initial discovery.
2025-10-30 16:00:44 -03:00
moothz
5cbc163716 Update channel.service.ts 2025-10-30 10:58:24 -03:00
ricael
a84faaa575 refactor(utils): improve makeProxyAgent for Undici compatibility 2025-10-30 10:55:47 -03:00
ricael
503cbfb21c Merge branch 'fix/business_api' into improv/update_baileys_version 2025-10-30 10:49:37 -03:00
KokeroO
40281871c8 fix: improve code formatting and consistency in makeProxyAgent.ts 2025-10-29 23:07:31 -03:00
KokeroO
85868b3439 chore: package 2025-10-29 22:59:18 -03:00
KokeroO
066e060b86 fix: baileys and chatwoot 2025-10-29 22:52:20 -03:00
Davidson Gomes
c555048783
Merge pull request #2155 from gomessguii/develop
Some checks failed
Check Code Quality / check-lint-and-build (push) Has been cancelled
Build Docker image / Build and Deploy (push) Has been cancelled
Security Scan / CodeQL Analysis (javascript) (push) Has been cancelled
Security Scan / Dependency Review (push) Has been cancelled
Fix merge
2025-10-29 17:39:30 -03:00
Guilherme Gomes
2d14c8849b Merge branch 'main' into develop 2025-10-29 17:38:15 -03:00
Davidson Gomes
df20c5fc93
Merge pull request #2141 from JefersonRamos/bugfix/media-upload-failed-on-all-hosts
Some checks failed
Check Code Quality / check-lint-and-build (push) Has been cancelled
Build Docker image / Build and Deploy (push) Has been cancelled
Security Scan / CodeQL Analysis (javascript) (push) Has been cancelled
Security Scan / Dependency Review (push) Has been cancelled
fix: "Media upload failed on all hosts" utilizando proxy
2025-10-29 17:14:23 -03:00
Jeferson Ramos
3818313161 fix: handle undefined protocol in makeProxyAgent 2025-10-27 10:40:10 -03:00
Jeferson Ramos
4a38e505f4 Esse erro acontece porque o Node.js (a partir da versão 18) usa o Undici como implementação nativa de fetch(), e o Undici não aceita mais objetos agent tradicionais (como os criados por https-proxy-agent ou socks-proxy-agent).
Ele espera objetos compatíveis com a interface moderna Dispatcher, que possuem o método dispatch().

Ou seja, o Baileys estava recebendo um tipo de agente incompatível com o novo sistema de rede do Node.

Foi criada uma nova função makeProxyAgentUndici() para gerar agentes de proxy compatíveis com o Undici, mantendo a versão antiga (makeProxyAgent()) inalterada para compatibilidade com bibliotecas como Axios.

A nova função substitui os antigos HttpsProxyAgent e SocksProxyAgent por ProxyAgent da biblioteca undici, garantindo compatibilidade total com o Baileys e com qualquer uso de fetch() moderno.
2025-10-27 10:20:34 -03:00
Davidson Gomes
d5f5b8325e
Merge pull request #2120 from FaelN1/develop
Some checks failed
Check Code Quality / check-lint-and-build (push) Has been cancelled
Build Docker image / Build and Deploy (push) Has been cancelled
Security Scan / CodeQL Analysis (javascript) (push) Has been cancelled
Security Scan / Dependency Review (push) Has been cancelled
fix(chat): apply where filters correctly in findContacts endpoint
2025-10-23 06:55:28 -03:00
Rafael Nicolas
1ad51a434b fix(chat): apply where filters correctly in findContacts endpoint
Anteriormente, o endpoint findContacts processava apenas o campo remoteJid da cláusula where, ignorando outros campos como id e pushName.

Alterações:

- Atualiza método fetchContacts para processar todos os campos do where (id, remoteJid, pushName)

- Adiciona campo remoteJid ao contactValidateSchema para validação adequada

- Garante isolamento multi-tenant mantendo filtro por instanceId

Esta correção permite que usuários filtrem contatos por qualquer um dos campos suportados ao invés de sempre retornar todos os contatos da instância.
2025-10-22 23:52:48 -03:00
Davidson Gomes
3454bec79f Merge branch 'release/2.3.6'
Some checks failed
Check Code Quality / check-lint-and-build (push) Has been cancelled
Build Docker image / Build and Deploy (push) Has been cancelled
Security Scan / CodeQL Analysis (javascript) (push) Has been cancelled
Security Scan / Dependency Review (push) Has been cancelled
2025-10-21 11:40:39 -03:00
Davidson Gomes
8c27f11f5b chore(changelog): update to version 2.3.6
Some checks failed
Security Scan / Dependency Review (push) Has been cancelled
Security Scan / CodeQL Analysis (javascript) (push) Has been cancelled
Check Code Quality / check-lint-and-build (push) Has been cancelled
Build Docker image / Build and Deploy (push) Has been cancelled
2025-10-21 11:40:27 -03:00
Davidson Gomes
ae9f3efeff
Merge pull request #2108 from KokeroO/develop
chore: bump version to 2.3.6 and update baileys dependency to 7.0.0-rc.6
2025-10-21 09:00:58 -03:00