Skip to content

MSC3758: Add event_property_is push rule condition kind #3758

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Mar 5, 2023
57 changes: 57 additions & 0 deletions proposals/3758-expand-push-rule-conditions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# MSC3758: Expand push rule conditions

Currently the only condition used to match event content for push rules is the `event_match` kind.
This compares a glob-style string against a string value within the event dictionary. The event
dictionary is flattened before conditions are checked to enable mathing nested values.

This approach is currently limited to only checking for string values within the event dictionary
(at any level). This MSC proposes a new exact match type for event content that works with all
JSON types.


## Proposal

### Exact matching event data

We propose a new type of condition, `exact_event_match`. Similar to the current `event_match`
([link to spec](https://spec.matrix.org/v1.3/client-server-api/#conditions-1)), this condition
takes two parameters: `value` and `key`. The exact match compares the `value` to the event data
associated with `key` exactly. Both type and content (when a string) should be identical. This allows
for matching all valid JSON types `null`, `true`, `false` and numbers. This also provides a simpler
exact string matching mechanism (and any associated performance gains on implementation side without
globbing).

An example condition may look like (encoded as a JSON object):

```json
{
"kind": "exact_event_match",
"key": "event.content.is_something",
"value": true
}
```


## Alternatives

[MSC3862](https://github.com/matrix-org/matrix-spec-proposals/pull/3862) proposes an alternative
solution by converting non-string JSON objects to strings in the `event_match` condition type.

## Security considerations

None.

## Unstable prefix

While still not part of the Matrix spec, the new rule type should be prefixed as so:

```json
{
"kind": "com.beeper.msc3758.exact_event_match",
"key": "..."
}
```

## Dependencies

None.