Commit Graph
30 Commits
Author SHA1 Message Date
1sonhador f55a38c032 feat: paginate emails list in API and admin UI
Return total count with offset/limit from GET /messages and add
Anterior/Seguinte controls showing 25 rows per page.
2026-07-01 09:19:17 +01:00
1sonhador b070af8503 fix: forward original email via SMTP instead of .eml attachment
Re-send the received RFC822 message with normal Fwd headers (To, From,
Subject). The previous code wrapped the message in message/rfc822 with
filename original-email.eml, which the relay rejected.
2026-07-01 09:18:11 +01:00
1sonhador f664cca6b5 fix: forward invoice PDF/XML/ZIP attachments instead of .eml wrapper
The outbound SMTP relay rejects message/rfc822 attachments named .eml.
Send the matched invoice files directly to BizDocs, which aligns with
the allowed relay extensions and the product filter rules.
2026-07-01 09:15:01 +01:00
1sonhador 87b1ad4b8a feat: sync UI controls, message retry, and worker schedule guard
Add manual sync buttons with batch limit, nginx timeouts for long syncs,
message retry endpoint, and fix worker to skip disabled accounts and
refresh schedules from the database every 2 minutes.
2026-07-01 09:10:04 +01:00
XikaandPaperclip 20966501a8 fix(deploy): retry API health check after container restart
After --force-recreate web, the API container can take >10s to become
healthy. Retry up to 5 times with 5s backoff so transient startup
latency doesn't mark a successful deploy as failed.

Co-Authored-By: Paperclip <[email protected]>
2026-07-01 01:23:15 +00:00
XikaandPaperclip 41ba0befe6 chore(deploy): document webhook URL via NPM proxy
Gitea hook #28 now delivers to http://forwarder-hook.bitreport.pt/
(NPM CT 102 → 10.10.50.43:9090) instead of direct VLAN IP,
as Gitea VLAN 1010 cannot route to VLAN 1050 directly.

Co-Authored-By: Paperclip <[email protected]>
2026-07-01 01:13:27 +00:00
XikaandPaperclip 146593bf05 chore(deploy): document webhook URL via NPM proxy
Gitea hook #28 now delivers to http://forwarder-hook.bitreport.pt/
(NPM CT 102 → 10.10.50.43:9090) instead of direct VLAN IP,
as Gitea VLAN 1010 cannot route to VLAN 1050 directly.

Co-Authored-By: Paperclip <[email protected]>
2026-07-01 01:13:19 +00:00
Xika c834560f81 fix(accounts): add POST /accounts/{id}/test combined endpoint (BIT-26141)
The admin UI calls POST /accounts/{id}/test when the user clicks "Testar
ligação", but only granular /test/imap, /test/smtp, /test/send endpoints
existed — causing a 404. Adds the missing combined endpoint that runs
IMAP + SMTP tests in parallel and returns the ConnectionTestResult schema
the frontend expects (imap_ok, smtp_ok, bizdocs_ok).

Paperclip-Issue: BIT-26141
2026-07-01 01:13:06 +00:00
XikaandPaperclip c281b2b56d fix(deploy): write status before self-restarting deploy-hook
The deploy-hook container was killing itself before write_status ran,
leaving last_deploy=null on every successful deploy. Move health check
and write_status before the detached nohup restart of the deploy-hook
container so status is persisted even when the container recreates itself.

Co-Authored-By: Paperclip <[email protected]>
2026-07-01 01:02:00 +00:00
1sonhador df016a1e34 fix(deploy): use repo deploy script + expose git_sha in health
Webhook now runs /opt/forwarder/deploy/deploy-pull.sh from git (not stale
image copy). Rolling rebuild api then web; health reports FORWARDER_GIT_SHA.
2026-07-01 01:40:43 +01:00
1sonhador 210bc7e324 fix(api): default destination_email for legacy UI payloads
Accept account creates without destination_email (defaults to BizDocs
inbox) and force admin-ui rebuild on deploy so web container picks up UI changes.
2026-07-01 01:36:07 +01:00
1sonhador eb4a95dfc2 fix(admin-ui): add destination_email field to account form
The API requires destination_email for BizDocs SMTP forwarding; the UI
still sent legacy bizdocs_api_key fields. Default [email protected].
2026-07-01 01:29:44 +01:00
XikaandPaperclip 0c63ae7fbd feat: integrate error hub (errors.bitreport.pt) for runtime error reporting
- Add forwarder/error_reporter.py: Python client for v1/ingest/events
  with cooldown-based dedup, best-effort delivery, and env-driven config
- Add FastAPI global exception handler to report unhandled 500s
- Report sync failures and forward failures from sync_service.py
- Report scheduler job failures from worker/scheduler.py with cooldown
- Report startup failures (ensure_admin_user) from app.py
- Report worker crashes from cli.py entry point
- Add error hub env vars to config.py (pydantic-settings)
- Update .env.example with ERROR_REPORTING_TOKEN and related vars
- Exclude IMAP/SMTP connection test errors per BIT-26136 scope note
- Uses project_slug=bizdocs-forwarder, gitea_repo=BitReport.pt/forwarder

Co-Authored-By: Paperclip <[email protected]>
2026-07-01 00:14:29 +00:00
1sonhador f6b276511a fix(connection): fail-fast IMAP/SMTP tests; add Gitea webhook autodeploy
Connection tests use 5s timeouts and run IMAP/SMTP in parallel so the UI
gets a clear error instead of nginx 504. Add deploy-hook service (:9090) and
deploy-pull.sh for push-to-main deploys on CT 243.
2026-07-01 01:09:53 +01:00
XikaandPaperclip d476cb0204 feat(admin-ui): add login page and HTTP Basic auth
- AuthProvider + useAuth hook (sessionStorage, base64 creds)
- Login.tsx validates credentials against /api/stats before accepting
- api.ts injects Authorization: Basic header on all requests
- App.tsx gates all routes behind login, redirects unknown paths
- Layout.tsx adds logout button
- .gitignore: allow admin-ui/src/lib/ (was blocked by root lib/ rule)

Co-Authored-By: Paperclip <[email protected]>
2026-06-30 23:50:01 +00:00
XikaandPaperclip 6e6f1a44e4 fix(nginx): use hostname variable in proxy_pass to fix DNS + path rewriting
Using $variable:port with no path appended forces DNS re-resolution
while nginx still forwards the full original request URI unchanged.
Previous attempt ($upstream/api/) was dropping the request path.

Co-Authored-By: Paperclip <[email protected]>
2026-06-30 23:46:47 +00:00
XikaandPaperclip 3436611714 fix(api+nginx): fix 502 proxy, add /stats + /connection/test, align UI schema
- nginx: add resolver 127.0.0.11 + $upstream var to fix Docker DNS caching
- Add GET /api/stats (accounts/messages counts, last_sync_at)
- Add POST /api/connection/test (IMAP+SMTP inline test)
- AccountResponse: computed active/email aliases, bizdocs stub fields
- MessageResponse: account_name, message_uid, sender, received_at, forwarded_at
- AccountCreate/Update: accept extra UI fields without validation error

Co-Authored-By: Paperclip <[email protected]>
2026-06-30 23:43:11 +00:00
XikaandPaperclip 34f7fd9cdd feat(deploy): add MySQL backup script (daily cron, 14-day retention)
Installed in CT 244 at /opt/forwarder/backup-mysql.sh with
/etc/cron.d/forwarder-backup running at 03:00 UTC daily.

Co-Authored-By: Paperclip <[email protected]>
2026-06-30 23:34:12 +00:00
XikaandPaperclip 7100440294 fix(auth): replace passlib with direct bcrypt (compat with bcrypt>=4.0)
passlib 1.7.4 detect_wrap_bug crashes with bcrypt>=4.0 which enforces
72-byte password limit. Use bcrypt directly instead.

Co-Authored-By: Paperclip <[email protected]>
2026-06-30 23:28:48 +00:00
XikaandPaperclip f3d2533db5 fix(migrations): remove TEXT server_default (MySQL incompatible)
Co-Authored-By: Paperclip <[email protected]>
2026-06-30 23:15:40 +00:00
XikaandPaperclip b211d9d8df fix(compose): use alembic migrate service; drop init.sql; use env vars for mysql creds
Co-Authored-By: Paperclip <[email protected]>
2026-06-30 23:09:39 +00:00
XikaandPaperclip fd1c1b1ba3 merge: reconcile docker-compose with origin/main (use admin-ui/Dockerfile for web)
Co-Authored-By: Paperclip <[email protected]>
2026-06-30 23:07:23 +00:00
1sonhador d1e4725ac3 Add Python API, worker, MySQL migrations and wire admin-ui in Docker.
Backend FastAPI + APScheduler worker with Alembic schema; admin-ui served
via nginx with /api proxy. Unifies Paperclip UI scaffold with local platform code.
2026-07-01 00:04:57 +01:00
XikaandPaperclip d8daca15bd feat(backend): add FastAPI, worker, web nginx — full platform (BIT-26121)
- api/: FastAPI app with MySQL (accounts, forwarding_rules, messages)
  - GET/POST/PUT/DELETE /accounts + /accounts/{id}/test
  - GET /messages + /messages/{id}/retry
  - GET /stats
  - POST /connection/test
  - Auto-runs migrations/init.sql on startup
- worker/: Python IMAP poller + BizDocs upload (schedule every 5 min)
- web/: multi-stage Dockerfile — builds admin-ui via Node, serves via nginx
  - nginx proxies /api/ → api:8000, SPA fallback for React Router
- docker-compose.yml: updated web build context + mysql init.sql mount

Co-Authored-By: Paperclip <[email protected]>
2026-06-30 23:04:54 +00:00
spark 305570458b Merge pull request 'feat(admin-ui): Vite+React Admin UI — BIT-26126' (#1) from task/BIT-26126-admin-ui into main 2026-07-01 00:02:36 +01:00
Xika 8e02d4123b Merge remote-tracking branch 'origin/task/BIT-26126-admin-ui' into task/BIT-26121-backend 2026-06-30 23:01:32 +00:00
XikaandPaperclip acbb1d9be4 feat(admin-ui): add Vite+React admin UI (BIT-26126)
Dashboard, Contas, Emails, Teste de Ligação pages built with
React Router, Tailwind CSS, and lucide-react icons. Typed API
client covers accounts CRUD, messages list/retry, stats, and
connection testing (IMAP/SMTP/BizDocs). Clean TypeScript build.

Co-Authored-By: Paperclip <[email protected]>
2026-06-30 22:54:31 +00:00
spark 09bab7ac0b feat: add .env.example with all required variables (BIT-26128) 2026-06-30 23:53:25 +01:00
spark f2f706d500 feat: add docker-compose.yml with mysql/api/worker/web stack (BIT-26128) 2026-06-30 23:53:17 +01:00
sparkandPaperclip 073f05f4e7 feat: initial repo setup — BizDocs Forwarder
README with architecture overview, stack, and getting-started guide.
.gitignore for Python/Docker projects.

Co-Authored-By: Paperclip <[email protected]>
2026-06-30 22:45:20 +00:00