Commit Graph
29 Commits
Author SHA1 Message Date
Ian Couto 4c3453a5ea fix(auth): allow Hobby clock tick through edge auth
/api/v1/system/relogio/tick authenticates with Bearer INTERNAL_SECRET
inside the route. Without a PUBLIC_PATHS entry the proxy returned 401
before the handler ran, so GitHub Actions could never advance follow-ups.
2026-08-26 08:43:31 -03:00
Ian Couto c68afd1a40 feat(relogio): enhance HTTP clock functionality and documentation
- Updated `relogio.yml` to clarify scheduling requirements and added concurrency settings for better job management.
- Introduced a new runbook `vercel-hobby-relogio.md` detailing setup instructions for external cron jobs and GitHub Actions.
- Enhanced `executarTickDoRelogio` to improve logging of follow-up advancements, ensuring better tracking of inbound responses.
- Added PowerShell and Bash scripts to facilitate the activation of the clock with necessary commands for GitHub Actions and cron-job.org.
- Implemented tests to validate the clock workflow and URL generation for external cron jobs, ensuring reliability in scheduled task execution.
2026-08-25 21:35:21 -03:00
Ian Couto f88aa227bf feat(followup): refactor text application for follow-ups and enhance tests
- Renamed `aplicarTextoNosFollowups` to `aplicarTextoAosEnrollmentsEmEspera` for clarity and updated its parameters to improve functionality.
- Introduced a new test suite for `aplicarTextoNosFollowups`, ensuring proper application of text to follow-ups and validating the expected behavior.
- Enhanced existing tests to verify the integration of the new text application logic, improving overall test coverage and reliability.
2026-08-25 19:23:27 -03:00
Ian Couto 249eedae08 refactor(followup): enhance matchNode function for flexible configuration
- Updated the `matchNode` function to accept an optional `extra` parameter, allowing for dynamic configuration of `FlowNode` properties.
- Simplified test cases by utilizing the updated `matchNode` function to create nodes with specific configurations, improving code readability and maintainability.
- Adjusted related tests to ensure correct behavior with the new flexible node creation approach.
2026-08-25 19:07:54 -03:00
Ian Couto 78d012d821 feat(relogio): implement HTTP clock functionality for scheduled tasks
- Introduced a new workflow `relogio.yml` to handle scheduled HTTP requests every 5 minutes, allowing for external triggering of tasks.
- Added a new endpoint `POST /api/v1/system/relogio/tick` to process clock ticks, supporting both admin session and bearer token authentication.
- Implemented task execution logic in `executarTickDoRelogio`, enabling the processing of follow-up tasks and event log drainage without relying on cron jobs.
- Enhanced audit logging for clock tick actions to track task execution and outcomes.
- Created tests for the clock functionality to ensure reliability and correctness of scheduled task processing.
2026-08-25 17:46:38 -03:00
Ian Couto b049106a63 feat(followup): implement DELETE endpoint for followup flows
- Added a DELETE endpoint to remove followup flows, including associated enrollments and versions, ensuring proper cascading deletion.
- Introduced `DeleteFollowupFlowButton` component for UI integration, allowing users to delete flows from the interface.
- Updated `FlowsList` to include the delete button for each flow, enhancing user experience.
- Implemented necessary hooks and error handling for the deletion process, including success and error notifications.
- Enhanced audit logging to track deletion actions for followup flows.
- Added tests to verify the functionality of the DELETE endpoint and its integration in the UI.
2026-08-25 14:48:39 -03:00
Ian Couto a14c43b423 refactor(pipeline): enhance local pipeline processing with contact-specific handling
- Updated `kickLocalPipeline` to accept an optional contact parameter, allowing for targeted processing of follow-ups for specific contacts.
- Modified `POST` request handling in `route.ts` to pass contact details to the pipeline, improving lead processing efficiency.
- Introduced `aplicarEfeitosPosEntrada` in the ingestion process to ensure follow-ups are correctly applied based on inbound messages, enhancing overall responsiveness.
- Enhanced unit tests to verify the new behavior and ensure proper handling of contact-specific follow-up actions.
2026-08-25 14:12:56 -03:00
Ian Couto d5a617d1d6 fix(followup): aplica a resposta do lead mesmo com cadastro duplicado pelo telefone
A captação e o WhatsApp geravam dois contatos (grafias do nono dígito BR); o enrollment ficava waiting_reply no cadastro errado e o job de confirmação reenviava a pergunta. Casa gêmeos de telefone no inbound, não avança match_reply no sent, e canoniza o número na ingestão.
2026-08-25 09:54:24 -03:00
Ian Couto 31349b8267 feat(followup): implement inbound text application to active follow-ups
- Added `aplicarTextoNosFollowups` function to apply inbound text to active follow-ups for a contact.
- Updated `kick-local-pipeline.ts` to handle errors when applying inbound text and waking up follow-ups, improving robustness.
- Introduced unit tests for `textoDoPayloadInbound` to ensure correct extraction of text from inbound payloads.
- Registered `followupReactivityHandler` to process inbound messages and apply text to follow-ups, enhancing event handling.
2026-08-25 08:49:53 -03:00
Ian Couto db63bb0a49 fix(followup): repair broken NodeResult import that failed the Vercel build 2026-08-24 20:09:21 -03:00
Ian Couto 438b1a2d20 feat(followup): enhance match reply handling with conditional logic
- Updated `MatchReplyForm` to include an `ifExists` state, allowing users to specify behavior when a value already exists (skip, overwrite, or confirm).
- Enhanced the `commit` function to handle the new `ifExists` parameter, ensuring proper processing of match replies based on user input.
- Modified the `describeNodeConfig` function to reflect the new conditional logic in the match reply configuration.
- Updated the `matchReplyConfigSchema` to validate the new `if_exists` field, ensuring correct schema enforcement.
- Enhanced unit tests to cover new scenarios for handling existing values in match replies, improving overall reliability.
2026-08-24 20:06:20 -03:00
Ian Couto aec9ac8c4b refactor(pipeline): enhance event acceleration and follow-up processing
- Updated `acelerarPipelineDeEventos` to accept an optional inbound parameter, allowing for targeted follow-up wake-up based on specific message context.
- Introduced `acordarFollowupPorInbound` to handle follow-up events more efficiently, improving responsiveness during inbound lead processing.
- Enhanced unit tests to verify the correct invocation of event acceleration with the new parameters, ensuring proper follow-up behavior.
2026-08-24 19:27:27 -03:00
Ian Couto 4f0a7f973a refactor(pipeline): enhance follow-up processing and error handling
- Updated `tickFollowupAteParar` to return the number of claimed jobs, improving tracking of processed follow-ups.
- Introduced `enviarTextoFixoPendente` to handle sending fixed messages without relying on cron jobs or agent workers.
- Enhanced error handling in message sending to ensure jobs return to pending status on failure, improving reliability.
- Adjusted `acelerarPipelineDeEventos` to iterate through follow-up ticks and fixed message sending, optimizing event processing.
2026-08-24 19:18:58 -03:00
Ian Couto 7dbe7b3516 refactor(webhooks): enhance lead processing and pipeline handling
- Updated comments in `route.ts` to clarify the lead capture process and its implications in production environments.
- Modified `kickLocalPipeline` to ensure immediate processing of events in Vercel's Hobby plan, addressing the lack of a cron job.
- Adjusted `enroll.ts` to omit `next_eval_at` during enrollment, allowing the database's default behavior to manage timing.
- Enhanced unit tests to reflect changes in enrollment behavior and ensure proper handling of lead processing.
2026-08-24 19:12:29 -03:00
Ian Couto 6186383c31 feat(followup): integrate event pipeline acceleration and enhance wait node handling
- Added `acelerarPipelineDeEventos` function to streamline event processing during inbound lead responses, improving responsiveness.
- Updated `kickLocalPipeline` to utilize the new event acceleration function.
- Enhanced `processNode` to allow early wake-up of wait nodes based on lead responses, ensuring timely follow-up actions.
- Added unit tests to verify the new behavior of wake-up conditions for wait nodes.
2026-08-24 18:07:58 -03:00
Ian Couto 1439c5431a refactor(tests): enhance fakePool query type definition for improved clarity
- Updated the type definition of the `query` function in the `fakePool` to return a more specific promise type, ensuring better type safety and clarity in unit tests.
- Added comments to clarify the behavior of SQL responses, enhancing the understanding of the test setup.
2026-08-24 17:52:37 -03:00
Ian Couto 945e02c932 refactor: streamline follow-up turn handling and enhance error management
- Removed redundant code for resolving conversation and channel session IDs in the follow-up turn handler.
- Introduced a new `resolveSendTarget` function to encapsulate logic for determining the appropriate send target, improving code clarity and maintainability.
- Updated error handling to provide clearer messages when a contact cannot be resumed or when a channel is archived.
- Enhanced unit tests to cover new scenarios for handling contacts without conversations and ensuring proper follow-up flow.
2026-08-24 17:51:43 -03:00
Ian Couto f6f85f7b53 refactor: clean up imports and enhance sound playback functionality
- Removed duplicate imports in _client.tsx and LeadFieldsForm.tsx for improved code clarity.
- Updated playSound function to accept a volume parameter, allowing for customizable sound playback levels.
- Adjusted beep function to utilize the new volume parameter, enhancing audio control during notifications.
- Added tests for new volume functionality in sounds.test.ts to ensure reliability.
2026-08-24 17:23:11 -03:00
Ian Couto a811d7eb7e refactor: remove agent logging from automation and webhook handling
- Eliminated redundant logging fetch calls from various automation functions and webhook routes to streamline code and improve performance.
- Added a new trigger kind "case_opened" in TriggerConfigControl for better categorization of follow-up actions.
- Cleaned up imports in LeadFieldsForm and KanbanBoard components to remove duplicates and enhance readability.
2026-08-24 17:15:54 -03:00
Ian Couto b3740a3e83 Merge branch 'main' of https://github.com/IanCouto/DeskcommCRM into feat/inbox-compartilhar-contato 2026-08-24 17:15:41 -03:00
Ian Couto 93e2481d3f feat(automation): add Web Push notifications and cron job configuration
- Introduced `VAPID_PUBLIC_KEY` and `VAPID_PRIVATE_KEY` to `.env.example` and `.env.hostgator.example` for enabling Web Push notifications.
- Updated `CHANGELOG.md` to document the addition of system alerts with the browser minimized.
- Enhanced `next.config.ts` to support Web Push by adding appropriate headers.
- Added a new script command `dev:crons` in `package.json` for local cron job development.
- Updated dependencies to include `web-push` and its types for TypeScript support.
- Created new design and specification documents for CRM automation flows, detailing the architecture and user stories for visual automation flows.
2026-08-24 17:07:14 -03:00
Ian Couto c16ccd31af feat(inbox): compartilhar contato no composer com cartao clicavel no WhatsApp
Permite enviar cartoes de contato pelo inbox (CRM ou telefone manual), com suporte WAHA e Meta Cloud, resolucao do wa_id via check-exists para o nono digito BR, e abertura da conversa ao tocar no cartao dentro do CRM.
2026-08-19 14:30:18 -03:00
Ian Couto a7afbdd382 fix(contacts): data fixa na ultima atividade apos ontem
Hoje e ontem continuam relativos; datas mais antigas exibem dd/MM/yyyy em vez do dia da semana.
2026-08-19 14:15:04 -03:00
Ian Couto 61dc7c3242 fix(contacts): atualiza ultima atividade e ordenacao no backend
Mensagens passam a carimbar contacts.last_activity_at via fn_mark_conversation_message (migration 0162) e envio pelo CRM. A lista /app/contacts ganha order_by/order_dir, cursor corrigido e UI com colunas ordenaveis e paginacao por backend.
2026-08-19 14:11:00 -03:00
Ian Couto 7230025f3c Merge pull request #2 from IanCouto/fix/inbox-unread-badge
fix(inbox): corrige badge de mensagens pendentes na fila
2026-08-19 13:55:55 -03:00
Ian Couto 4e2f756119 fix(inbox): corrige badge de mensagens pendentes na fila
O contador só subia em inbound e nunca zerava ao responder, inflando o badge (ex.: 6 com 1 mensagem pendente). Outbound passa a zerar unread, o envio CRM espelha isso, mark-read cobre leitura sem resposta, e a migration recalcula contadores stale.
2026-08-19 13:54:35 -03:00
Ian Couto 830896a66a Merge pull request #1 from IanCouto/fix/whatsapp-sessao-permanece-conectada
Fix/whatsapp sessao permanece conectada
2026-08-19 13:49:41 -03:00
Ian Couto 4776bfc189 feat(contacts): atalho para abrir conversa no Inbox
Lista e detalhe do contato passam a trazer a conversa mais recente e oferecem link direto para o Inbox. O composer também limpa o campo na hora do envio, sem travar até a API responder.
2026-08-19 13:48:18 -03:00
Ian Couto ba6de26b05 feat(docker): add WHATSAPP_RESTART_ALL_SESSIONS configuration to restart stopped sessions
Updated docker-compose files to include the WHATSAPP_RESTART_ALL_SESSIONS environment variable, set to "True" by default. This change ensures that stopped sessions are resumed automatically without requiring user intervention. Additionally, added unit tests to verify the behavior of session resumption logic in the session reconciler.
2026-08-17 16:01:30 -03:00