feat(mail): mailstandardfilter write endpoints — add / delete#189
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Wires
add_mailstandardfilter/delete_mailstandardfilterthrough the sharedkaswriteseam plus the #109 / #131 / #132 CLI plumbing.Both subcommands are gated: the KAS API has no
update_mailstandardfilter, soaddreplaces the configured filter chain wholesale, anddeleteremoves every configured filter in one shot (no per-item delete on the wire). Repeatable--filteritems are joined with;; per-item rules reject empty items and items containing the separator. Thedeleteconfirm 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 PHPsizeof()fault thatdeletesometimes returns even after the chain was removed server-side. The fault is surfaced verbatim;docs/usage/destructive-writes.mddocuments 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.