Issue Description
Creating a masked address with emailDomain fails with forbidden / “The specified domain is not valid for this account.” for every domain, including the domain of the account’s own primary address, when the account has aliases on more than one domain.
Creating without emailDomain works and picks the primary address’s domain.
Reproduction Steps
-
Account
[email protected]with an alias[email protected](both domains local). -
Logged in as that account:
stalwart-cli create MaskedEmail --field emailDomain=example.com→
forbidden, “The specified domain is not valid for this account.” Same forexample.org. -
Without the field:
stalwart-cli create MaskedEmail --field description=test→ created on
example.com.
Stalwart Version
v0.16.x
Installation Method
Binary (Linux)
Database Backend
RocksDB
Blob Storage
RocksDB
Search Engine
Internal
Directory Backend
Internal
Additional Context
crates/jmap/src/registry/mapping/masked_email.rs, around line 78:
.filter(|domain| {
account
.addresses
.iter()
.all(|addr| addr.domain_id == domain.id)
})
.all() requires every address on the account to be in the requested domain, so any account with addresses on two domains can never pass. The intent looks like “the account has an address on this domain”, which is .any():
.any(|addr| addr.domain_id == domain.id)
The existing test in tests/src/system/delivery.rs only uses an account whose addresses are all on one domain, so it doesn’t catch this.
Separately (possibly intended)
Creating as an admin with --field accountId=<id> returns invalidForeignKey for a valid account id, so masked addresses can only be created by logging in as the owning account. If admins are meant to be able to create them for other accounts, that looks like a second bug.
I have reviewed the documentation and FAQ and confirm that my issue is NOT addressed there.
on
I have searched this support forum (open and closed topics) and confirm this is not a duplicate.
on
I understand that topics in this category are triaged by a bot first but a human reply will follow up. If I’d prefer a human-only reply, I’ll add the no-ai tag to my topic.
on