Commit Graph
7 Commits
Author SHA1 Message Date
Linus Rath 08969fde67 fix: stop reading a mail server's answer past a size limit in the JMAP, WebDAV, push preview and agenda routes 2026-10-26 14:52:04 +01:00
Linus Rath 60c2dbdcb4 fix: reload a failed calendar range and expand multi-word event searches
Four smaller calendar fixes found in review of the Stalwart 1.0 work.

- A range load that failed left `dateRange` on the range loaded before,
  so a push or a pull-to-refresh reloaded that one instead of the range
  on screen, and any action that reset `error` hid the "may be out of
  date" notice. The store now takes the range asked for and keeps the
  failure in `eventsLoadError`, which only a successful range load
  clears.
- The agenda plugin's expanded query had no sort, so its limit could
  keep later occurrences instead of the next ones. It now sorts by
  start, looks less far ahead when the server refuses the range as too
  long (`expandDurationTooLarge`, an administrator's shorter
  `maxExpandedQueryDuration`) instead of answering 502, and sends its
  gets several per request.
- With a limit (search, contact activity) the chunks of a long range
  went out one request each. Up to four now share a request, and what
  the later ones return past the limit is dropped. Global search passes
  its AbortSignal down, so a replaced search stops between requests.
- A search of several words sends its date bounds as conditions of a
  flat AND. The client did not see them as a range: it neither expanded
  recurrences nor turned the UTC bounds into the request's wall clock,
  so such a search found series instead of occurrences, over a range
  shifted by the zone's offset. The bounds are now lifted out of the
  AND, converted and chunked, and each chunk keeps one flat AND of
  single conditions - the shape 1.0 expands; it refuses an AND holding
  a condition with both bounds.
2026-09-25 19:42:38 +02:00
Linus Rath 19c2dfb2b4 fix: keep the calendar working on Stalwart 1.0 with an unknown time zone
Stalwart 1.0 fails every CalendarEvent get and query whose `timeZone`
argument names a zone missing from its time zone database, with
invalidArguments "Invalid timeZone". 0.16 reads such a zone as UTC, so
the calendar kept working there; on 1.0 it would stay empty.

- check the user's zone with a get of no events that rides along with
  the session's first calendar list
- once the server refuses the zone, ask in UTC, move the grid's
  wall-clock range bounds to UTC as well, and log one console warning
- repeat a read that was refused before the check answered, once, in
  UTC
2026-09-25 19:35:08 +02:00
Linus Rath 6dc9d5a584 fix: refetch mail when the server's change state goes backwards
Stalwart's change ids only grow. An upgrade that keeps the old change
log but restarts the counters lower (1.0 counts per collection where
0.16 counted per account) makes Email/changes and Mailbox/changes
accept an old state and answer with a lower `newState` and no changes,
so the delta sync would silently skip everything that changed since.

Read Stalwart `s` states (LEB128 in Stalwart's base32) and treat a
`newState` below `sinceState` like `cannotCalculateChanges`: fetch in
full. The check runs only on accounts that list `urn:stalwart:jmap`,
only for states in the exact form Stalwart writes, and never trips
while states go up.
2026-09-25 18:04:26 +02:00
Linus Rath c236d828c1 fix: keep the calendar filled when scrolling past a year on Stalwart 1.0
Stalwart 1.0 refuses an expanded CalendarEvent/query longer than
maxExpandedQueryDuration (365 days by default) with
expandDurationTooLarge. The scrolling month view reaches 777 days and
search with after:/before: can span years, so the grid went blank.

Range queries are now split into chunks within the advertised limit and
merged. A chunk the server still refuses is halved; if a week still
expands to too many occurrences, the range is expanded in the browser
as before. 0.16 advertises the same limit without enforcing it and
returns the same events.
2026-09-25 17:38:49 +02:00
Linus Rath 8db65135c6 fix: load calendar events and tasks on Stalwart 1.0
Stalwart 1.0 refuses a CalendarEvent/get that asks for
recurrenceOverrides together with utcStart or utcEnd, and every calendar
read did. The grid, tasks, reminders, search, contact activity and the
agenda plugin came back empty with no error, and creating an event or
task threw after the server had created it, so a retry made a
duplicate.

- read overrides with a second get in the same request, only where
  they are needed
- treat an error answer to a get or query as a failure; the calendar
  keeps the last events and says it could not load them, with a retry
- never throw after the server created an event or task
- let the server expand series for /api/calendar-agenda
2026-09-25 17:30:42 +02:00
Stefan Hildebrandt 2fac6ebfb8 test: add characterisation tests for untested integration seams
Golden-master tests pinning the CURRENT behavior of high-value modules
that had no coverage — integration seams, security helpers, two API
route handlers, and complex pure utils. 111 tests across 12 files.

New tests:
- auth-crypto / session-cookie: AES-256-GCM session encryption roundtrip,
  tamper/version/missing-secret handling; cookie-slot naming.
- unified-mailbox: multi-account fan-out, sort, totals, per-account error
  isolation, personal-vs-shared JMAP target resolution, counts/roles.
- account-state-manager: snapshot/restore across the six real Zustand
  stores; clearAllStores reset shape; evict.
- mdn: RFC 5322 MDN assembly (CRLF, RFC2047, base64 wrap, headers).
- tnef: winmail.dat binary parsing from hand-built fixtures.
- download-filename / subject-prefix / birthday-calendar / eml-import:
  filename templating, multilingual prefix stripping, birthday event
  generation, .eml/.zip import.
- webdav / caldav-discover route handlers: auth guards, path validation,
  upstream URL construction, candidate probing.
- helpers/factories.ts: shared makeEmail/makeMailbox/makeFakeJmapClient.

Tests follow the repo's existing patterns (route-import, fake IJMAPClient,
fetch spy, real store singletons). Where current behavior looks buggy it
is pinned and flagged with a // CHARACTERISATION: comment (see PR for the
suspected-bugs list); no production code is changed.
2026-06-19 23:52:42 +02:00