Merge pull request #2591 from matrix-org/travis/unsigned
Fix a number of issues with unsigned event objects
This commit is contained in:
commit
9281d0ca13
6 changed files with 57 additions and 36 deletions
|
@ -0,0 +1 @@
|
|||
Fix issues with ``age`` and ``unsigned`` being shown in the wrong places.
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
34
event-schemas/schema/core-event-schema/unsigned_prop.yaml
Normal file
34
event-schemas/schema/core-event-schema/unsigned_prop.yaml
Normal file
|
@ -0,0 +1,34 @@
|
|||
# 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: The event that redacted this event, if any.
|
||||
title: Event
|
||||
type: object
|
||||
transaction_id:
|
||||
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
|
|
@ -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:
|
||||
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
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue