Skip to content

Commit 9281d0c

Browse files
authored
Merge pull request #2591 from matrix-org/travis/unsigned
Fix a number of issues with unsigned event objects
2 parents cf37688 + 7fc811d commit 9281d0c

File tree

6 files changed

+57
-36
lines changed

6 files changed

+57
-36
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix issues with ``age`` and ``unsigned`` being shown in the wrong places.
Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
{
2-
"age": 242352,
2+
"$ref": "core/state_event.json",
3+
"type": "m.room.server_acl",
4+
"state_key": "",
35
"content": {
46
"allow_ip_literals": false,
57
"allow": ["*"],
68
"deny": ["*.evil.com", "evil.com"]
7-
},
8-
"state_key": "",
9-
"origin_server_ts": 1431961217939,
10-
"event_id": "$WLGTSEFSEF:localhost",
11-
"type": "m.room.server_acl",
12-
"room_id": "!Cuyf34gef24t:localhost",
13-
"sender": "@example:localhost"
9+
}
1410
}

event-schemas/schema/core-event-schema/sync_room_event.yaml

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,7 @@ properties:
3434
type: integer
3535
format: int64
3636
unsigned:
37-
description: Contains optional extra information about the event.
38-
properties:
39-
age:
40-
description: The time in milliseconds that has elapsed since the event was
41-
sent. This field is generated by the local homeserver, and may be incorrect
42-
if the local time on at least one of the two servers is out of sync, which can
43-
cause the age to either be negative or greater than it actually is.
44-
type: integer
45-
redacted_because:
46-
description: Optional. The event that redacted this event, if any.
47-
title: Event
48-
type: object
49-
transaction_id:
50-
description: The client-supplied transaction ID, if the client being given
51-
the event is the same one which sent it.
52-
type: string
53-
title: UnsignedData
54-
type: object
37+
$ref: unsigned_prop.yaml
5538
required:
5639
- event_id
5740
- sender
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Copyright 2020 The Matrix.org Foundation C.I.C.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
title: UnsignedData
16+
type: object
17+
description: Contains optional extra information about the event.
18+
properties:
19+
age:
20+
description: The time in milliseconds that has elapsed since the event was
21+
sent. This field is generated by the local homeserver, and may be incorrect
22+
if the local time on at least one of the two servers is out of sync, which can
23+
cause the age to either be negative or greater than it actually is.
24+
type: integer
25+
redacted_because:
26+
description: The event that redacted this event, if any.
27+
title: Event
28+
type: object
29+
transaction_id:
30+
description: |
31+
The client-supplied transaction ID, for example, provided via
32+
``PUT /_matrix/client/r0/rooms/{roomId}/send/{eventType}/{txnId}``,
33+
if the client being given the event is the same one which sent it.
34+
type: string

event-schemas/schema/m.room.member

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,6 @@ properties:
100100
- signed
101101
title: Invite
102102
type: object
103-
unsigned:
104-
type: object
105-
title: UnsignedData
106-
description: Contains optional extra information about the event.
107-
properties:
108-
invite_room_state:
109-
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.'
110-
items:
111-
$ref: "stripped_state.yaml"
112-
type: array
113103
required:
114104
- membership
115105
title: EventContent
@@ -124,5 +114,15 @@ properties:
124114
enum:
125115
- m.room.member
126116
type: string
117+
unsigned:
118+
allOf:
119+
- $ref: "core-event-schema/unsigned_prop.yaml"
120+
- type: object
121+
properties:
122+
invite_room_state:
123+
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.'
124+
items:
125+
$ref: "stripped_state.yaml"
126+
type: array
127127
title: The current membership state of a user in the room.
128128
type: object

scripts/templating/matrix_templates/units.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,13 @@ def read_event_schema(self, filepath):
910910
Units.prop(json_schema, "properties/content")
911911
)
912912

913+
# Include UnsignedData if it is present on the object
914+
unsigned = Units.prop(json_schema, "properties/unsigned")
915+
if unsigned:
916+
tbls = get_tables_for_schema(unsigned)
917+
for tbl in tbls:
918+
schema["content_fields"].append(tbl)
919+
913920
# grab msgtype if it is the right kind of event
914921
msgtype = Units.prop(
915922
json_schema, "properties/content/properties/msgtype/enum"

0 commit comments

Comments
 (0)