From ffea5d5e610f429b558e07df3f3d00f1b74a9aeb Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Sun, 31 May 2020 21:36:47 -0600 Subject: [PATCH 1/7] Document top-level UnsignedData objects --- scripts/templating/matrix_templates/units.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/templating/matrix_templates/units.py b/scripts/templating/matrix_templates/units.py index 5a7ff94e..ff614e34 100644 --- a/scripts/templating/matrix_templates/units.py +++ b/scripts/templating/matrix_templates/units.py @@ -910,6 +910,13 @@ class MatrixUnits(Units): Units.prop(json_schema, "properties/content") ) + # Include UnsignedData if it is present on the object + unsigned = Units.prop(json_schema, "properties/unsigned") + if unsigned: + tbls = get_tables_for_schema(unsigned) + for tbl in tbls: + schema["content_fields"].append(tbl) + # grab msgtype if it is the right kind of event msgtype = Units.prop( json_schema, "properties/content/properties/msgtype/enum" From 1c1e3517782484df5947a4686974f5a5782883c9 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Sun, 31 May 2020 21:37:18 -0600 Subject: [PATCH 2/7] Move m.room.member's unsigned data to the top level --- event-schemas/schema/m.room.member | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/event-schemas/schema/m.room.member b/event-schemas/schema/m.room.member index 1ccf5ab3..7fe23f40 100644 --- a/event-schemas/schema/m.room.member +++ b/event-schemas/schema/m.room.member @@ -100,16 +100,6 @@ properties: - signed title: Invite type: object - unsigned: - type: object - title: UnsignedData - description: Contains optional extra information about the event. - properties: - invite_room_state: - description: 'A subset of the state of the room at the time of the invite, if ``membership`` is ``invite``. Note that this state is informational, and SHOULD NOT be trusted; once the client has joined the room, it SHOULD fetch the live state from the server and discard the invite_room_state. Also, clients must not rely on any particular state being present here; they SHOULD behave properly (with possibly a degraded but not a broken experience) in the absence of any particular events here. If they are set on the room, at least the state for ``m.room.avatar``, ``m.room.canonical_alias``, ``m.room.join_rules``, and ``m.room.name`` SHOULD be included.' - items: - $ref: "stripped_state.yaml" - type: array required: - membership title: EventContent @@ -124,5 +114,15 @@ properties: enum: - m.room.member type: string + unsigned: + type: object + title: UnsignedData + description: Contains optional extra information about the event. + properties: + invite_room_state: + description: 'A subset of the state of the room at the time of the invite, if ``membership`` is ``invite``. Note that this state is informational, and SHOULD NOT be trusted; once the client has joined the room, it SHOULD fetch the live state from the server and discard the invite_room_state. Also, clients must not rely on any particular state being present here; they SHOULD behave properly (with possibly a degraded but not a broken experience) in the absence of any particular events here. If they are set on the room, at least the state for ``m.room.avatar``, ``m.room.canonical_alias``, ``m.room.join_rules``, and ``m.room.name`` SHOULD be included.' + items: + $ref: "stripped_state.yaml" + type: array title: The current membership state of a user in the room. type: object From 33d738e6650037824e52ace02407dd120c0ef803 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Sun, 31 May 2020 21:41:29 -0600 Subject: [PATCH 3/7] Document the m.room.member unsigned object in full --- .../core-event-schema/sync_room_event.yaml | 19 +---------- .../core-event-schema/unsigned_prop.yaml | 32 +++++++++++++++++++ event-schemas/schema/m.room.member | 18 +++++------ 3 files changed, 42 insertions(+), 27 deletions(-) create mode 100644 event-schemas/schema/core-event-schema/unsigned_prop.yaml diff --git a/event-schemas/schema/core-event-schema/sync_room_event.yaml b/event-schemas/schema/core-event-schema/sync_room_event.yaml index 8006148f..fef13ad0 100644 --- a/event-schemas/schema/core-event-schema/sync_room_event.yaml +++ b/event-schemas/schema/core-event-schema/sync_room_event.yaml @@ -34,24 +34,7 @@ properties: type: integer format: int64 unsigned: - description: Contains optional extra information about the event. - properties: - age: - description: The time in milliseconds that has elapsed since the event was - sent. This field is generated by the local homeserver, and may be incorrect - if the local time on at least one of the two servers is out of sync, which can - cause the age to either be negative or greater than it actually is. - type: integer - redacted_because: - description: Optional. The event that redacted this event, if any. - title: Event - type: object - transaction_id: - description: The client-supplied transaction ID, if the client being given - the event is the same one which sent it. - type: string - title: UnsignedData - type: object + $ref: unsigned_prop.yaml required: - event_id - sender diff --git a/event-schemas/schema/core-event-schema/unsigned_prop.yaml b/event-schemas/schema/core-event-schema/unsigned_prop.yaml new file mode 100644 index 00000000..39cfb267 --- /dev/null +++ b/event-schemas/schema/core-event-schema/unsigned_prop.yaml @@ -0,0 +1,32 @@ +# Copyright 2020 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +title: UnsignedData +type: object +description: Contains optional extra information about the event. +properties: + age: + description: The time in milliseconds that has elapsed since the event was + sent. This field is generated by the local homeserver, and may be incorrect + if the local time on at least one of the two servers is out of sync, which can + cause the age to either be negative or greater than it actually is. + type: integer + redacted_because: + description: Optional. The event that redacted this event, if any. + title: Event + type: object + transaction_id: + description: The client-supplied transaction ID, if the client being given + the event is the same one which sent it. + type: string diff --git a/event-schemas/schema/m.room.member b/event-schemas/schema/m.room.member index 7fe23f40..36490c6b 100644 --- a/event-schemas/schema/m.room.member +++ b/event-schemas/schema/m.room.member @@ -115,14 +115,14 @@ properties: - m.room.member type: string unsigned: - type: object - title: UnsignedData - description: Contains optional extra information about the event. - properties: - invite_room_state: - description: 'A subset of the state of the room at the time of the invite, if ``membership`` is ``invite``. Note that this state is informational, and SHOULD NOT be trusted; once the client has joined the room, it SHOULD fetch the live state from the server and discard the invite_room_state. Also, clients must not rely on any particular state being present here; they SHOULD behave properly (with possibly a degraded but not a broken experience) in the absence of any particular events here. If they are set on the room, at least the state for ``m.room.avatar``, ``m.room.canonical_alias``, ``m.room.join_rules``, and ``m.room.name`` SHOULD be included.' - items: - $ref: "stripped_state.yaml" - type: array + allOf: + - $ref: "core-event-schema/unsigned_prop.yaml" + - type: object + properties: + invite_room_state: + description: 'A subset of the state of the room at the time of the invite, if ``membership`` is ``invite``. Note that this state is informational, and SHOULD NOT be trusted; once the client has joined the room, it SHOULD fetch the live state from the server and discard the invite_room_state. Also, clients must not rely on any particular state being present here; they SHOULD behave properly (with possibly a degraded but not a broken experience) in the absence of any particular events here. If they are set on the room, at least the state for ``m.room.avatar``, ``m.room.canonical_alias``, ``m.room.join_rules``, and ``m.room.name`` SHOULD be included.' + items: + $ref: "stripped_state.yaml" + type: array title: The current membership state of a user in the room. type: object From 0f9ffdf01ade1e680c503525cf0c0dbc04505f55 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Sun, 31 May 2020 21:43:27 -0600 Subject: [PATCH 4/7] Make server ACL example inherit from state events --- event-schemas/examples/m.room.server_acl | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/event-schemas/examples/m.room.server_acl b/event-schemas/examples/m.room.server_acl index 86da2093..06586f79 100644 --- a/event-schemas/examples/m.room.server_acl +++ b/event-schemas/examples/m.room.server_acl @@ -1,14 +1,10 @@ { - "age": 242352, + "$ref": "core/state_event.json", + "type": "m.room.server_acl", + "state_key": "", "content": { "allow_ip_literals": false, "allow": ["*"], "deny": ["*.evil.com", "evil.com"] - }, - "state_key": "", - "origin_server_ts": 1431961217939, - "event_id": "$WLGTSEFSEF:localhost", - "type": "m.room.server_acl", - "room_id": "!Cuyf34gef24t:localhost", - "sender": "@example:localhost" + } } From 33309fb68ece8264245ff2ab40bfd171b5610de0 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Sun, 31 May 2020 21:46:15 -0600 Subject: [PATCH 5/7] Add changelog --- changelogs/client_server/newsfragments/2591.clarification | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelogs/client_server/newsfragments/2591.clarification diff --git a/changelogs/client_server/newsfragments/2591.clarification b/changelogs/client_server/newsfragments/2591.clarification new file mode 100644 index 00000000..7473f453 --- /dev/null +++ b/changelogs/client_server/newsfragments/2591.clarification @@ -0,0 +1 @@ +Fix issues with ``age`` and ``unsigned`` being shown in the wrong places. From 8532cfd706a199d44bdc7358b8c88c2c7d643aef Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Mon, 1 Jun 2020 20:35:22 -0600 Subject: [PATCH 6/7] Clarify which transaction ID --- event-schemas/schema/core-event-schema/unsigned_prop.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/event-schemas/schema/core-event-schema/unsigned_prop.yaml b/event-schemas/schema/core-event-schema/unsigned_prop.yaml index 39cfb267..9571c33b 100644 --- a/event-schemas/schema/core-event-schema/unsigned_prop.yaml +++ b/event-schemas/schema/core-event-schema/unsigned_prop.yaml @@ -27,6 +27,8 @@ properties: title: Event type: object transaction_id: - description: The client-supplied transaction ID, if the client being given - the event is the same one which sent it. + description: | + The client-supplied transaction ID, for example, provided via + ``PUT /_matrix/client/r0/rooms/{roomId}/send/{eventType}/{txnId}``, + if the client being given the event is the same one which sent it. type: string From 7fc811d4bdf276d54c3571416628616466ae10ca Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Tue, 2 Jun 2020 15:10:18 -0600 Subject: [PATCH 7/7] Update event-schemas/schema/core-event-schema/unsigned_prop.yaml Co-authored-by: Hubert Chathi --- event-schemas/schema/core-event-schema/unsigned_prop.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/event-schemas/schema/core-event-schema/unsigned_prop.yaml b/event-schemas/schema/core-event-schema/unsigned_prop.yaml index 9571c33b..36c37230 100644 --- a/event-schemas/schema/core-event-schema/unsigned_prop.yaml +++ b/event-schemas/schema/core-event-schema/unsigned_prop.yaml @@ -23,7 +23,7 @@ properties: cause the age to either be negative or greater than it actually is. type: integer redacted_because: - description: Optional. The event that redacted this event, if any. + description: The event that redacted this event, if any. title: Event type: object transaction_id: