Skip to content

feat: add email forwarding management UI#138

Closed
filippoadessi wants to merge 1 commit intostalwartlabs:mainfrom
filippoadessi:feature/email-forwards
Closed

feat: add email forwarding management UI#138
filippoadessi wants to merge 1 commit intostalwartlabs:mainfrom
filippoadessi:feature/email-forwards

Conversation

@filippoadessi
Copy link
Copy Markdown

Summary

Adds a dedicated email forwarding management section to the Directory module, allowing administrators to create, edit, and delete per-address forwarding rules without manually editing Sieve scripts.

Storage model

Rules are stored in the settings store under mail.forward.<from_address>.*:

  • mail.forward.<addr>.to.0, .to.1, … — destination addresses (array)
  • mail.forward.<addr>.keep-copy — boolean; when true uses Sieve :copy to keep a local mailbox copy

A per-domain Sieve trusted script (sieve.trusted.scripts.<domain_underscored>.contents) is generated, updated, or deleted automatically on every create / edit / delete operation.

New pages

  • Directory → Forwards (/manage/directory/forwards) — paginated list with search and bulk delete; Sieve scripts are rebuilt on deletion.
  • Directory → Forwards → Edit (/manage/directory/forwards/:id/edit) — create or edit a rule: source address (fixed on edit), one or more destination addresses, keep-copy toggle.

Inline editing in the Account detail page

The account edit page (/manage/directory/accounts/:id/edit) gains a Forwarding tab for Individual accounts. The UI mirrors the existing Aliases field: a stacked list of editable inputs with add/remove buttons and a keep-copy checkbox. Forward settings are loaded automatically when the account is opened and saved atomically together with "Save changes" — no separate save step required.

Test plan

  • Create a forward rule from the Forwards list page; verify the Sieve script appears under sieve.trusted.scripts
  • Edit the rule (change destinations, toggle keep-copy); verify the script is updated
  • Delete the rule; verify the script is removed when no rules remain for that domain
  • Open an Individual account, set forward addresses in the Forwarding tab, save; verify settings and Sieve script
  • Clear all forward addresses for an account and save; verify settings and script are removed
  • Verify the Forwards menu entry is only visible to users with settings-list permission

🤖 Generated with Claude Code

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Adds a dedicated email forwarding management section to the Directory
module that allows administrators to manage per-address forwarding rules
without manually editing Sieve scripts.

## Storage model

Rules are persisted in the settings store under the prefix
`mail.forward.<from_address>.*`:

- `mail.forward.<addr>.to.0`, `.to.1`, … — destination addresses
- `mail.forward.<addr>.keep-copy` — boolean (deliver to local mailbox too)

A per-domain Sieve script (`sieve.trusted.scripts.<domain_underscored>.contents`)
is generated / updated / deleted automatically on every create, edit, or
delete operation.  The script uses the `redirect` extension; when
`keep-copy` is true it uses `:copy` to keep a local copy.

## New pages

- **Directory → Forwards** (`/manage/directory/forwards`)
  List view with search, pagination, bulk-delete, and inline Sieve
  script rebuild on deletion.

- **Directory → Forwards → Edit** (`/manage/directory/forwards/:id/edit`)
  Create / edit a forward rule: from-address (fixed on edit), one or
  more destination addresses (textarea, comma/newline/semicolon
  separated), keep-copy toggle.

## Inline editing in Account detail

The account edit page (`/manage/directory/accounts/:id/edit`) gains a
**Forwarding** tab for Individual accounts.  The UI mirrors the Aliases
field: a stacked list of editable address inputs with add/remove buttons.
Forward settings are loaded on account open and saved atomically with
"Save changes" — no separate save step.

## Files changed

- `src/pages/directory/forward/mod.rs` — `ForwardRule`, helpers
  (`forward_prefix`, `build_sieve_script`, `domain_script_id`), and the
  `AccountForwardSection` Leptos component used inside the account editor
- `src/pages/directory/forward/list.rs` — `ForwardList` component,
  `parse_forward_settings`, `rebuild_sieve_for_domains`,
  `fetch_all_forwards`
- `src/pages/directory/forward/edit.rs` — `ForwardEdit` component
- `src/pages/directory/mod.rs` — `pub mod forward`
- `src/pages/directory/edit.rs` — forward signals, load resource, save
  integration, new Forwarding tab with `AccountForwardSection`
- `src/main.rs` — routes `/directory/forwards` and
  `/directory/forwards/:id/edit`; menu entries under Directory (both
  desktop and mobile layouts)
- `src/pages/config/mod.rs` — minor cleanup
@filippoadessi filippoadessi force-pushed the feature/email-forwards branch from e36d21c to 998e0c1 Compare March 22, 2026 17:51
@stappersg
Copy link
Copy Markdown

Text from #137 (comment)

Hi, thanks for the PR but this can't be merged as we're about to rewrite the webadmin from scratch using Leptos 0.8 and the new v0.16 JMAP API.

@mdecimus
Copy link
Copy Markdown
Member

Thanks but AI generated code is not accepted. In addition to that the webadmin is going to be rewritten from scratch in the next few days.

@mdecimus mdecimus closed this Mar 22, 2026
@filippoadessi
Copy link
Copy Markdown
Author

filippoadessi commented Mar 22, 2026 via email

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.

4 participants