Mail rules: group and tenant ids in their JMAP form
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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user