Description
JMap filtering spec
A Filter is a per-user singleton ordered list of Rules.
For each received mail the Filter is triggered by walk in the order through the Rule until a condition is met, which selects the corresponding Rule.
Once the selection is done, the action part is executed and we consider the filtering as done.
Objects
Rule
- id: String
- name: String
- condition: Condition
- action: Action
Action
- mailboxIds: [String]
Condition
- field: String we manage the following fields: from, to, cc, subject, recipient (to or cc)
- comparator: String we manage the following behavior: contains, not-contains, exactly-equals, not-exactly-equals
value: String
Methods
setFilter
setFilter takes only one parameter which is all the Rules.
[[ "setFilter", { "ifInState": "4011", //can be null "singleton": [ { "id": "42-ac", "name": "My first rule" "condition": { "field": "from", "comparator": "exactly-equals" "value": "marvin@h2.g2" }, "action": { "mailboxIds": ["5"] } }, { "id": "3000-34e", "name": "My last rule" "condition": { "field": "subject", "comparator": "contains" "value": "question" }, "action": { "mailboxIds": ["7", "2", "5"] } } ]}, "#0" ]]
getFilter
getFilter takes no parameters and returns the filter with all the Rules.
{ "getFilter", {}, "#0" }
Will return:
[[ "filter", { "state": "4012", "singleton": [ { "id": "42-ac", "name": "My first rule" "condition": { "field": "from", "comparator": "exactly-equals" "value": "marvin@h2.g2" }, "action": { "mailboxIds": ["5"] } }, { "id": "3000-34e", "name": "My last rule" "condition": { "field": "subject", "comparator": "contains" "value": "question" }, "action": { "mailboxIds": ["7", "2", "5"] } } ]}, "#0" ]]