Commit Graph
13 Commits
Author SHA1 Message Date
Gustavo c7157ce96a Fix opt-out correctness: estagio=opt_out now blocks the number, numbers normalized to digits
Marking a lead opt_out via /estagio only wrote outreach_lead_states/
outreach_stage_events and never called addOptOut, so the lead stayed fully
eligible for future campaign sends. Also normalize numero with onlyDigits
in POST/DELETE opt-out routes and in the estagio lookup, matching how every
other number in the app (leads.whatsapp, queue.numero) is stored, so opt-out
comparisons never silently miss due to formatting differences.
2026-08-03 13:06:25 -03:00
Gustavo 0d360ad652 Add campaign HTTP routes 2026-08-03 08:17:36 -03:00
Gustavo 4835c6e085 Wire campaign scheduler into server boot 2026-08-03 08:13:45 -03:00
Gustavo a9509a4691 Add campaign send worker with daily limit and health auto-pause 2026-08-03 08:09:45 -03:00
Gustavo a2ecb135d4 Add campaign health auto-pause and variant comparison stats 2026-08-03 08:04:48 -03:00
Gustavo 9bf77d88d3 Fix candidatosEncontrados to reflect full eligible pool, not post-slice count
generateCampaignQueue computed candidatosEncontrados after slicing to
quantidade, so it could never differ from adicionadosNaFila. An operator
generating a queue with quantidade smaller than the eligible pool saw no
signal that more eligible leads existed. Now candidatosEncontrados is read
before the slice, while adicionadosNaFila still reflects rows actually
inserted.
2026-08-01 10:37:31 -03:00
Gustavo 248bd4c550 Add campaign candidate selection, queue generation and approval 2026-08-01 10:32:39 -03:00
Gustavo 8600893496 Add deterministic variant selection and message rendering 2026-08-01 10:29:19 -03:00
GustavoandClaude Sonnet 5 577f48ab19 Fix: stamp semana_iniciada_em when campaign first transitions to 'rodando'
Previously, setCampaignStatus did not set semana_iniciada_em, causing
escalateWeeklyLimits to bail early (if (!campaign.semana_iniciada_em) continue).
Now when a campaign transitions to 'rodando' for the first time, semana_iniciada_em
is set to datetime('now'). Subsequent rodando transitions leave it unchanged
(using COALESCE to preserve first-run timestamp).

Regression tests confirm:
- First transition to 'rodando' stamps semana_iniciada_em
- Subsequent transitions do not reset the timestamp
- resumeCampaign continues to work correctly (pause/resume cycle)
- All 105 tests pass

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-01 10:25:00 -03:00
Gustavo fb2cd75a56 Add campaign-store: CRUD, opt-out and weekly limit escalation 2026-08-01 10:19:22 -03:00
Gustavo a7abd3d4d0 Add campaign outreach schema (migration v8) 2026-08-01 10:14:54 -03:00
Gustavo 4f736562f3 Carry over pre-existing WABA outreach automation WIP
This work already existed uncommitted in the main working tree (not
authored by this branch) and is required as a runtime dependency for the
campaign outreach port (zpro-client, templates, outreach routes/UI). Copied
in as-is, untouched, so this feature branch has a working baseline; the
original uncommitted state in the main checkout is left exactly as it was.
2026-08-01 10:12:25 -03:00
DESKTOP-F2O4A80\UserandClaude b8d10b210c Commit inicial: GTI Maquina Comercial
App local (Node + SQLite) para captura, tratamento e exportacao de leads
comerciais, com dashboard de gestao, login/usuarios e integracao Z-PRO.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-12 14:22:21 -03:00