-
Notifications
You must be signed in to change notification settings - Fork 400
MSC3966: event_property_contains
push rule condition
#3966
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
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
proposals/3966-exact-event-property-contains-push-condition.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# MSC3966: `exact_event_property_contains` push rule condition | ||
|
||
[MSC3952](https://github.com/matrix-org/matrix-spec-proposals/pull/3952): | ||
Intentional mentions requires a way for a push rule condition to search | ||
for a value in a JSON array of values. This proposes implementing it in a | ||
generic fashion for re-use with other push rules. | ||
|
||
## Proposal | ||
|
||
A new push rule condition `exact_event_property_contains` is added which acts like | ||
[`event_match`](https://spec.matrix.org/v1.5/client-server-api/#conditions-1), | ||
but searches an array for an exact value. The values must match exactly and be a | ||
non-compound JSON types allowed by [canonical JSON](https://spec.matrix.org/v1.5/appendices/#canonical-json): | ||
clokep marked this conversation as resolved.
Show resolved
Hide resolved
|
||
i.e. strings, `null`, `true`, `false` and integers. | ||
|
||
An example condition would look like: | ||
|
||
```json | ||
{ | ||
"kind": "exact_event_property_contains", | ||
"key": "content.my_array", | ||
"value": "foo" | ||
} | ||
``` | ||
|
||
This would match an event with content: | ||
|
||
```json | ||
{ | ||
"content": { | ||
"my_array": ["foo", true] | ||
} | ||
} | ||
``` | ||
|
||
And it would not match if `my_array` was empty or did not exist. | ||
|
||
## Potential issues | ||
|
||
None foreseen. | ||
|
||
## Alternatives | ||
|
||
[MSC3887](https://github.com/matrix-org/matrix-spec-proposals/pull/3887) is an | ||
unfinished alternative which suggests allowing [`event_match`](https://spec.matrix.org/v1.5/client-server-api/#conditions-1) | ||
to search in arrays without other changes. | ||
|
||
## Security considerations | ||
|
||
It is possible for the event content to contain very large arrays (the | ||
[maximum event size](https://spec.matrix.org/v1.5/client-server-api/#size-limits) | ||
is 65,536 bytes, if most of that contains an array of empty strings you get | ||
somewhere around 20,000 entries). Iterating through arrays of this size should | ||
not be a problem for modern computers, especially since the push rule searches | ||
for *exact* matches. | ||
|
||
## Unstable prefix | ||
|
||
During development `org.matrix.msc3966.exact_event_property_contains` shall be | ||
used in place of `exact_event_property_contains`. | ||
|
||
## Dependencies | ||
|
||
This MSC has similar semantics to [MSC3758](https://github.com/matrix-org/matrix-spec-proposals/pull/3758) | ||
(and the implementation builds on that), but it does not strictly depend on it. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.