|
| 1 | +# MSC3966: `event_property_contains` push rule condition |
| 2 | + |
| 3 | +[MSC3952](https://github.com/matrix-org/matrix-spec-proposals/pull/3952): |
| 4 | +Intentional mentions requires a way for a push rule condition to search |
| 5 | +for a value in a JSON array of values. This proposes implementing it in a |
| 6 | +generic fashion for re-use with other push rules. |
| 7 | + |
| 8 | +## Proposal |
| 9 | + |
| 10 | +A new push rule condition `event_property_contains` is added which acts like |
| 11 | +[`event_match`](https://spec.matrix.org/v1.5/client-server-api/#conditions-1), |
| 12 | +but searches an array for an exact value. The values must match exactly and be a |
| 13 | +non-compound JSON type allowed by [canonical JSON](https://spec.matrix.org/v1.5/appendices/#canonical-json): |
| 14 | +i.e. strings, `null`, `true`, `false` and integers. |
| 15 | + |
| 16 | +An example condition would look like: |
| 17 | + |
| 18 | +```json |
| 19 | +{ |
| 20 | + "kind": "event_property_contains", |
| 21 | + "key": "content.my_array", |
| 22 | + "value": "foo" |
| 23 | +} |
| 24 | +``` |
| 25 | + |
| 26 | +This would match an event with content: |
| 27 | + |
| 28 | +```json |
| 29 | +{ |
| 30 | + "content": { |
| 31 | + "my_array": ["foo", true] |
| 32 | + } |
| 33 | +} |
| 34 | +``` |
| 35 | + |
| 36 | +And it would not match if `my_array` was empty or did not exist. |
| 37 | + |
| 38 | +## Potential issues |
| 39 | + |
| 40 | +None foreseen. |
| 41 | + |
| 42 | +## Alternatives |
| 43 | + |
| 44 | +[MSC3887](https://github.com/matrix-org/matrix-spec-proposals/pull/3887) is an |
| 45 | +unfinished alternative which suggests allowing [`event_match`](https://spec.matrix.org/v1.5/client-server-api/#conditions-1) |
| 46 | +to search in arrays without other changes. |
| 47 | + |
| 48 | +## Security considerations |
| 49 | + |
| 50 | +It is possible for the event content to contain very large arrays (the |
| 51 | +[maximum event size](https://spec.matrix.org/v1.5/client-server-api/#size-limits) |
| 52 | +is 65,536 bytes, if most of that contains an array of empty strings you get |
| 53 | +somewhere around 20,000 entries). Iterating through arrays of this size should |
| 54 | +not be a problem for modern computers, especially since the push rule searches |
| 55 | +for *exact* matches. |
| 56 | + |
| 57 | +## Unstable prefix |
| 58 | + |
| 59 | +During development `org.matrix.msc3966.exact_event_property_contains` shall be |
| 60 | +used in place of `event_property_contains`. |
| 61 | + |
| 62 | +## Dependencies |
| 63 | + |
| 64 | +This MSC has similar semantics to [MSC3758](https://github.com/matrix-org/matrix-spec-proposals/pull/3758) |
| 65 | +(and the implementation builds on that), but it does not strictly depend on it. |
0 commit comments