Skip to content

feat(mail): mailstandardfilter write endpoints — add / delete#189

Merged
chmmou merged 2 commits into
mainfrom
feature/mailfilter-write
May 23, 2026
Merged

feat(mail): mailstandardfilter write endpoints — add / delete#189
chmmou merged 2 commits into
mainfrom
feature/mailfilter-write

Conversation

@chmmou

@chmmou chmmou commented May 23, 2026

Copy link
Copy Markdown
Owner

Wires add_mailstandardfilter / delete_mailstandardfilter through the shared kaswrite seam plus the #109 / #131 / #132 CLI plumbing.

Both subcommands are gated: the KAS API has no update_mailstandardfilter, so add replaces the configured filter chain wholesale, and delete removes every configured filter in one shot (no per-item delete on the wire). Repeatable --filter items are joined with ;; per-item rules reject empty items and items containing the separator. The delete confirm verb is "remove all standard filters of mail account" to make the all-at-once effect explicit.

A new shared envelope-level fault fixture (testdata/response_failed_internal_server_error.xml) captures the observed PHP sizeof() fault that delete sometimes returns even after the chain was removed server-side. The fault is surfaced verbatim; docs/usage/destructive-writes.md documents the verification path (mail accounts get <login>mail_spamfilter).

The maintainer refreshed three fixtures against the live API (add_mailstandardfilter_{request,response_success}.xml, get_mailstandardfilter_response_success.xml); existing read tests pass unchanged.

Closes #116.

chmmou added 2 commits May 23, 2026 15:53
Wires add_mailstandardfilter and delete_mailstandardfilter through the
shared kaswrite seam plus the #109 / #131 / #132 CLI plumbing as a
vertical slice (Closes #116, part of #13). Both subcommands are gated:
the KAS API has no update action, so add replaces the configured filter
chain wholesale, and delete removes every configured filter in one shot.

- internal/mailfilter/write.go adds Client.Add/Delete (semicolon-joined
  --filter chain, per-field validation, kaswrite contract).
- internal/cli/mail.go wires "mail filters add | delete" with the
  destructive flag set, a confirm verb that phrases the all-at-once
  delete explicitly ("remove all standard filters of mail account
  <login>") and a Long help that points users at "mail accounts get
  <login>" → mail_spamfilter for outcome verification.
- testdata/response_failed_internal_server_error.xml captures the
  observed envelope-level PHP sizeof() fault that
  delete_mailstandardfilter sometimes returns even after the chain was
  removed; mailfilter.Client.Delete surfaces it verbatim (locked in by
  TestClientDeleteSurfacesInternalServerFault). docs/usage/
  destructive-writes.md documents the quirk + verification path.
- testdata/mailfilter/add_mailstandardfilter_{request,response_success}.xml
  and get_mailstandardfilter_response_success.xml refreshed against the
  live API by the maintainer; the slice's read tests still pass against
  the real-shape fixture.

Closes #116.
Post-#189-review blocker fix. AddParams previously joined the items
internally and discarded the JoinFilters error via blank assignment,
so a CLI dry-run / audit record could capture filter="" when the
user passed an empty --filter item or one containing the ';'
separator, while the dispatched Add call would later fail validation.
The audit log and the action it logs must not diverge.

- AddParams now takes the already-joined chain string and is a pure
  map builder; JoinFilters stays the single validator.
- Client.Add validates as before and routes through AddParams once
  joined.
- The CLI runWriteE closure validates via JoinFilters before building
  the writeSpec, so an invalid item produces a user error before the
  dry-run preview, the audit record or the prompt fire.
- TestMailFiltersAddRejectsBadFilter pins the new behaviour (empty
  item / embedded ';' both rejected; --dry-run --yes still runs the
  validator before any audit emission), TestParamBuilders aligned with
  the new AddParams signature.
@chmmou chmmou merged commit 40a063a into main May 23, 2026
6 checks passed
@chmmou chmmou deleted the feature/mailfilter-write branch May 23, 2026 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(mail): mailstandardfilter write endpoints — add / delete

1 participant