Commit Graph
81 Commits
Author SHA1 Message Date
Xika 969dbe08ce fix(crypto): catch ValueError on malformed Fernet key, raise EncryptionError (BIT-33940)
ci / verify (pull_request) Successful in 49s
get_fernet() only checked for an empty ENCRYPTION_KEY. A non-empty but
malformed key (not 32 url-safe base64 bytes) let Fernet() raise a raw
ValueError that crashed sync_account. Wrap the constructor and re-raise
as EncryptionError with a clear message.

Paperclip-BIT-33940
2026-12-04 10:18:29 +00:00
spark c389503fb9 Merge pull request 'fix(imap): catch TimeoutError on per-message fetch so sync continues (BIT-33891)' (#8) from fix/BIT-33891-imap-timeout into main
ci / verify (push) Successful in 32s
2026-12-03 23:31:18 +00:00
spark c9d1ad4b48 Merge pull request 'fix(imap): catch OSError on logout of timed-out socket (BIT-33892)' (#9) from fix/BIT-33892-imap-logout-oserror into main
ci / verify (push) Successful in 35s
2026-12-03 23:31:13 +00:00
Xika 3ca283aa41 fix(imap): catch OSError on logout of timed-out socket (BIT-33892)
ci / verify (pull_request) Successful in 27s
The finally block in sync_account and retry_single_message only caught
imaplib.IMAP4.error from imap.logout(). When the underlying socket had
already timed out, logout() raises OSError('cannot read from timed out
object') which escaped the handler and crashed the sync run.

Add OSError to the except tuple so cleanup completes cleanly.

Paperclip-BIT-33892
2026-12-03 23:22:43 +00:00
Xika 66dcd1f78e fix(imap): catch TimeoutError on per-message fetch so sync continues (BIT-33891)
ci / verify (pull_request) Successful in 26s
TimeoutError (OSError subclass) escaped the imaplib.IMAP4.error handler
in sync_account, killing the entire sync run on a single slow fetch.
Catch OSError alongside IMAP4.error to skip the timed-out message and
continue scanning.

Paperclip-BIT-33891
2026-12-03 23:17:08 +00:00
bug-squasher f39338a2a9 fix(webdav): fall back to Depth:1 recursion when PROPFIND infinity returns HTTP 500 (BIT-33518) (#7)
ci / verify (push) Successful in 28s
Depth:infinity PROPFIND returns HTTP 500 on servers that disable it (Nextcloud/ownCloud/mod_dav). list_files now falls back to recursive Depth:1 traversal, preserving full relative paths for year-folder filtering and dedup.

BIT-33518
Paperclip-Ref: BIT-33518
2026-11-29 01:18:42 +00:00
Xika e1ddd2a293 fix(webdav): fall back to Depth:1 recursion when PROPFIND infinity returns HTTP 500
ci / verify (pull_request) Successful in 30s
Some WebDAV servers (Nextcloud, ownCloud, Apache mod_dav with infinite
depth disabled) reject Depth:infinity PROPFIND with HTTP 500/403/501.
list_files now retries with a recursive Depth:1 traversal of child
collections, preserving full relative paths for year-folder filtering
and dedup keys.

BIT-33518
Paperclip-Ref: BIT-33518
2026-11-29 01:17:52 +00:00
spark f55629212c Merge pull request 'chore(runtime): PHP 8.5 + Node.js 24.22.1 baseline (BIT-31720)' (#6) from task/BIT-31720-runtime-baseline into main
ci / verify (push) Successful in 51s
Merge PR #6 (BIT-31720)
2026-10-23 18:43:33 +01:00
spark 0998a016fa ci(runtime): add PHP 8.5 and Node 24.22.1 CI workflow (BIT-31720)
ci / verify (pull_request) Successful in 41s
Paperclip-Issue: BIT-31720
2026-10-23 18:36:29 +01:00
spark e160520655 chore(runtime): pin .nvmrc to 24.22.1 (BIT-31720)
Paperclip-Issue: BIT-31720
2026-10-23 18:36:27 +01:00
spark 4998a0f009 chore(runtime): set engines.node >=24.22.1 in admin-ui (BIT-31720)
Paperclip-Issue: BIT-31720
2026-10-23 18:36:26 +01:00
spark a782a97a1d chore(runtime): update admin-ui/Dockerfile to latest PHP/Node baseline (BIT-31720)
Paperclip-Issue: BIT-31720
2026-10-23 18:36:23 +01:00
spark c0c3109174 chore(runtime): update web/Dockerfile to latest PHP/Node baseline (BIT-31720)
Paperclip-Issue: BIT-31720
2026-10-23 18:36:20 +01:00
spark 4fd7e51a7c chore(runtime): update deploy/Dockerfile to latest PHP/Node baseline (BIT-31720)
Paperclip-Issue: BIT-31720
2026-10-23 18:36:17 +01:00
spark ac932323c8 Merge pull request 'fix(webdav): PDF validation for WebDAV sync (BIT-26608)' (#5) from task/BIT-26608-webdav-pdf-validation into main 2026-07-15 01:37:27 +01:00
XikaandCursor 5bc5e0d889 fix(webdav): accept PDFs with leading bytes and JPEG-as-.pdf scans
WebDAV sync rejected valid files like 1784074260.pdf when the PDF magic
bytes were not at offset 0 (whitespace/BOM) or when a mobile scanner stored
JPEG bytes under a .pdf name. Scan the first 1KB for %PDF-, allow image
fallback for .pdf, and include validation detail in API errors.

Co-authored-by: Cursor <[email protected]>
2026-07-15 00:37:17 +00:00
spark bc39e00192 Merge pull request 'feat(imap): selectable folder sync per account (BIT-26607)' (#4) from task/BIT-26607-imap-folder-selection into main
Merge PR #4: feat(imap): selectable folder sync per account (BIT-26607)

BIT-26607 / BIT-26609
2026-07-15 01:35:23 +01:00
XikaandCursor c2524c31a5 feat(imap): selectable folder sync per account (BIT-26607)
Add default vs custom IMAP folder selection with live folder fetch in admin UI,
Alembic migration, sync filtering, and API endpoints for mailbox discovery.

Co-authored-by: Cursor <[email protected]>
2026-07-15 00:33:46 +00:00
spark 91b1a726e8 Merge pull request 'feat(scrapers): Amazon & Temu invoice downloader + BizDocs upload (BIT-26279/BIT-26280)' (#3) from task/BIT-26279-invoice-downloader into main 2026-07-06 23:31:33 +01:00
XikaandPaperclip d63a9e0290 feat(scrapers): add multi-portal invoice scraper with BizDocs upload (BIT-26282)
- Amazon and Temu Playwright-based invoice scrapers
- BizDocs mobile API client (login + document upload)
- ShopAccount DB model, migration 006, scheduler integration
- REST API routes: GET/POST/PATCH/DELETE /api/shop-accounts
- POST /api/shop-accounts/{id}/trigger for on-demand scrape
- POST /api/shop-accounts/{id}/test for BizDocs credential check
- GET /api/shop-accounts/{id}/runs for scrape history

Co-Authored-By: Paperclip <[email protected]>
2026-07-06 22:29:52 +00:00
spark a5256c45a5 Merge pull request 'fix(accounts): add POST /accounts/{id}/test combined endpoint (BIT-26141)' (#2) from task/BIT-26141-fix-test-endpoint into main
fix(accounts): add POST /accounts/{id}/test combined endpoint (BIT-26141)

Merged via CTO review - all approvals received.
2026-07-06 15:14:01 +01:00
spark 48d8ef2952 Merge branch 'main' into task/BIT-26141-fix-test-endpoint 2026-07-04 19:16:18 +01:00
1sonhador c83e452f54 fix: stop refresh from resetting sync job timers every 2 minutes
Account sync jobs were replaced on each schedule refresh, so the 15-minute
interval never elapsed and WebDAV/IMAP sync never ran after worker restarts.
2026-07-04 18:38:12 +01:00
1sonhador 7e5e4584fc fix: use WebDAV getlastmodified instead of Nextcloud epoch creationdate
Nextcloud returns DAV:creationdate as 1970 for bulk-imported files; the real
upload date is getlastmodified. Also pick the HTTP 200 propstat block.
2026-07-04 18:20:32 +01:00
1sonhador 3d81005588 fix: trust WebDAV folder year over 1970 epoch dates
Files under Faturas/2025/ or /2026/ are eligible even when Nextcloud
reports creationdate 1970. Add --requeue-folder-years to reset wrongly skipped records.
2026-07-04 18:13:41 +01:00
1sonhador a0f90bd8ef fix: skip WebDAV files smaller than 4KB to avoid retry loops
HTML stubs named as PDFs were stuck in the failed forward queue forever.
2026-07-04 13:19:02 +01:00
spark d8f298cec6 Merge branch 'main' into task/BIT-26141-fix-test-endpoint 2026-07-03 01:16:05 +01:00
1sonhador d561de7d02 feat: filter WebDAV files by creation/modified date instead of folders
Use PROPFIND creationdate with getlastmodified fallback so min year 2025 applies by file date, not folder names.
2026-07-02 23:13:31 +01:00
1sonhador 1617be3aee fix: detect WebDAV year folder anywhere in path (Faturas/2025/…) 2026-07-02 23:11:15 +01:00
1sonhador f381af9c60 fix: webdav year setup tool use get_session_factory() 2026-07-02 23:09:17 +01:00
1sonhador a4f4c2a921 fix: webdav year setup tool session import 2026-07-02 23:03:10 +01:00
1sonhador b02add914e fix: remove stale containers before compose recreate on deploy
Prevent docker name conflicts when a prior deploy fails mid-recreate.
2026-07-02 23:02:43 +01:00
1sonhador d3c26a453e fix: WebDAV year filter uses min year (2025+) not fixed list
Include all year folders from 2025 onwards (2026, 2027, …) and skip or mark anything older.
2026-07-02 22:51:35 +01:00
1sonhador 28164ad9f4 feat: filter WebDAV sync by year folders (2025/2026)
Add webdav_include_years account setting, skip files outside allowed year folders during sync, and a setup tool to mark older paths as already forwarded.
2026-07-02 22:45:03 +01:00
1sonhador 529ecb31a4 fix: unblock production deploy (API schema + admin UI types)
Remove duplicate bizdocs_entity_id field that broke API startup and fix nullable trim calls in Accounts form so the admin UI Docker build passes.
2026-07-02 22:22:03 +01:00
1sonhador 0f4bb5f522 feat: BizDocs API delivery, WebDAV source, and invoice validation
Add optional API upload alongside SMTP, Nextcloud/WebDAV as a document source with the same dedup/retry flow as IMAP, stricter invoice file checks for images, and admin UI for source and delivery modes.
2026-07-02 19:21:01 +01:00
spark f165f411d9 Merge branch 'main' into task/BIT-26141-fix-test-endpoint 2026-07-01 19:16:20 +01:00
1sonhador 6840e521dd fix: clarify sync test limit vs full scan; continue on rate limit
Test button (▶) caps UIDs scanned to N; full sync (↻) reads entire mailbox.
2026-07-01 14:48:26 +01:00
1sonhador 16816e9d4e feat: search emails by subject, sender, folder, Message-ID or id
API q parameter and debounced search field on the Emails admin page.
2026-07-01 14:44:00 +01:00
1sonhador e31a1b4a7a fix: sync_account must return SyncRun not last IMAP message
Fixes 500 on POST /accounts/{id}/sync when clicking play in admin UI.
2026-07-01 14:30:03 +01:00
spark b1382b4b95 Merge branch 'main' into task/BIT-26141-fix-test-endpoint 2026-07-01 13:16:23 +01:00
1sonhador 31d32ed1b4 fix: rebuild migrate image and run migrations before API restart
Ensures new Alembic revisions apply on deploy.
2026-07-01 11:27:30 +01:00
1sonhador 50b231caa6 feat: mark messages missing from IMAP and stop queue retries
New missing_from_mailbox status for deleted UIDs; migration backfills existing fetch failures.
2026-07-01 11:21:20 +01:00
1sonhador 5b841a8850 fix: skip known Message-IDs on sync and clarify email list UI
Sync ignores any message already in DB (queue handles retries). UI shows email date, folder, and Message-ID snippet.
2026-07-01 10:45:50 +01:00
1sonhador 2ee2306c3e fix: route retry-batch through forward queue instead of bulk SMTP
all=true only confirms failed messages are queued; each tick respects 5/min and 200/h limits.
2026-07-01 10:19:39 +01:00
1sonhador 9b966cf325 feat: forward queue drains failed messages at 5/min within 200/h cap
Worker ticks every 60s; API and UI expose queue status and requeue of forwarded messages for gradual BizDocs resend.
2026-07-01 10:14:18 +01:00
1sonhador 66d7189aa5 feat: cap SMTP forwards at 200 per rolling hour
Count successful forward_attempts in the last hour and stop sync/retry
when MAX_FORWARDS_PER_HOUR is reached to protect domain sending limits.
2026-07-01 10:09:52 +01:00
1sonhador 95edd74d9f fix: send clean invoice-only emails to avoid MailChannels spam blocks
Stop relaying the original RFC822 (SendGrid headers, Fwd: subject, etc.).
Send a new message with PDF/XML/ZIP attachments and minimal metadata body.
2026-07-01 09:56:38 +01:00
1sonhador f19886d78e fix: strip Cc/Bcc on forward to prevent mailbox loop
Re-sending the original MIME kept Cc/Bcc (e.g. faturas@) so copies
returned to the monitored inbox. Drop extra recipient headers and
send SMTP RCPT only to the BizDocs destination.
2026-07-01 09:51:00 +01:00
1sonhador ea88e8833d feat: retry all failed messages from emails page
Add "Repetir todas as falhadas" with batched API calls and progress
feedback; raise retry-batch limit to 100 and support all=true on API.
2026-07-01 09:44:19 +01:00