Mail rules: group and tenant ids in their JMAP form
ci / fork-checks (pull_request) Successful in 2m26s
ci / build (pull_request) Successful in 5m47s

senderGroup, senderTenant and recipientGroup conditions now read and write group and tenant ids as JMAP ids ("b", "c"…), like legal hold scopes and the rest of the API, so the console can use its object pickers; plain numbers are still read. Held as numbers for matching. Unit test for both forms and a bad id; mail_rules_tests round-trips a tenant condition over JMAP.
This commit is contained in:
2026-09-28 19:30:28 -07:00
parent de514115dd
commit 823d42d528
2 changed files with 80 additions and 0 deletions
+27
View File
@@ -114,6 +114,33 @@ pub async fn test(test: &mut TestServer) {
"{rule}"
);
// Group and tenant ids travel in their JMAP form
let mut by_tenant = transport_rule();
by_tenant["name"] = "By tenant".into();
by_tenant["conditions"] = json!([{"type": "senderTenant", "tenants": ["b"]}]);
let (_, response) = call(
&admin,
"inbuxa:MailRule/set",
json!({"create": {"g": by_tenant}}),
)
.await;
let tenant_rule = response["created"]["g"]["id"]
.as_str()
.unwrap_or_else(|| panic!("{response}"))
.to_string();
let (_, response) = call(&admin, "inbuxa:MailRule/get", json!({"ids": [tenant_rule]})).await;
assert_eq!(
response["list"][0]["conditions"][0]["tenants"],
json!(["b"]),
"{response}"
);
call(
&admin,
"inbuxa:MailRule/set",
json!({"destroy": [tenant_rule]}),
)
.await;
// Checked when written
let mut inbound = dlp_rule();
inbound["direction"] = "incoming".into();