Skip to content
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

Add event_property_is and event_property_contains props to PushConditions #1673

Merged
merged 3 commits into from Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1 @@
Add properties of `event_property_is` and `event_property_contains` to PushConditions
richvdh marked this conversation as resolved.
Show resolved Hide resolved
10 changes: 8 additions & 2 deletions data/api/client-server/definitions/push_condition.yaml
Expand Up @@ -23,8 +23,8 @@ properties:
key:
type: string
description: |-
Required for `event_match` conditions. The dot-separated field of the
event to match.
Required for `event_match`, `event_property_is` and `event_property_contains`
conditions. The dot-separated field of the event to match.

Required for `sender_notification_permission` conditions. The field in
the power level event the user needs a minimum power level for. Fields
Expand All @@ -43,5 +43,11 @@ properties:
optionally prefixed by one of, ==, <, >, >= or <=. A prefix of < matches
rooms where the member count is strictly less than the given number and
so forth. If no prefix is present, this parameter defaults to ==.
value:
type: ["string", "integer", "boolean", "null"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hrm. The spec displays this in a way that implies it should be an array. It looks like https://github.com/matrix-org/matrix-spec/blob/main/layouts/partials/openapi/render-object-table.html needs an update to handle this case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait. According to https://swagger.io/docs/specification/data-models/data-types/, this is not valid. "type as a list is not valid in OpenAPI (even though it is valid in JSON Schema)".

However, it is definitely a pattern we use elsewhere, such as here.

@KitsuneRal or @zecakeh, as people who know a lot more about OpenAPI than me: can you comment on this? Should we be updating the render-object-table to support multi-valued types? Or should we be using oneOf here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was not valid in OpenAPI 3.0, it is valid in OpenAPI 3.1, which is fully compatible with JSON Schema.

From "Migrating from OpenAPI 3.0 to 3.1.0":

In line with JSON Schema, the type keyword can now define multiple types for a schema with an array.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha, thanks for the clarification; that's very helpful.

In that case I guess we should merge this and file a separate issue to fix the template.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

description: |-
Required for `event_property_is` and `event_property_contains` conditions.
A non-compound [canonical JSON](/appendices#canonical-json) value to match
against.
Comment on lines +49 to +51
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the record:

I don't find the wording "a non-compound canonical JSON value" particularly clear, but it does match the existing wording in the Conditions section, so let's go with it.

required:
- kind