mirror of
https://github.com/matrix-org/matrix-spec
synced 2026-03-21 02:44:09 +01:00
Fix event schemas for /sync
This commit clarifies the required keys for each type of event that appears in sync, fixes the core event schema not declaring 'content' as required, and includes a mention that events may not have a room_id when appearing in /sync. Fixes https://github.com/matrix-org/matrix-doc/issues/595 Fixes https://github.com/matrix-org/matrix-doc/issues/909
This commit is contained in:
parent
32ce676eb6
commit
55c0b968b5
|
|
@ -1,4 +1,5 @@
|
||||||
# Copyright 2016 OpenMarket Ltd
|
# Copyright 2016 OpenMarket Ltd
|
||||||
|
# Copyright 2018 New Vector Ltd
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
|
|
@ -13,10 +14,10 @@
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
properties:
|
properties:
|
||||||
events:
|
events:
|
||||||
description: List of events
|
description: List of events.
|
||||||
items:
|
items:
|
||||||
allOf:
|
allOf:
|
||||||
- $ref: event.yaml
|
- $ref: event-schemas/schema/core-event-schema/event.yaml
|
||||||
type: object
|
type: object
|
||||||
type: array
|
type: array
|
||||||
type: object
|
type: object
|
||||||
|
|
|
||||||
27
api/client-server/definitions/room_event_batch.yaml
Normal file
27
api/client-server/definitions/room_event_batch.yaml
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
# Copyright 2018 New Vector Ltd
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
properties:
|
||||||
|
events:
|
||||||
|
description: List of events.
|
||||||
|
items:
|
||||||
|
allOf:
|
||||||
|
- $ref: event-schemas/schema/core-event-schema/sync_room_event.yaml
|
||||||
|
type: object
|
||||||
|
required:
|
||||||
|
- event_id
|
||||||
|
#- room_id - Not in /sync
|
||||||
|
- sender
|
||||||
|
- origin_server_ts
|
||||||
|
type: array
|
||||||
|
type: object
|
||||||
28
api/client-server/definitions/state_event_batch.yaml
Normal file
28
api/client-server/definitions/state_event_batch.yaml
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
# Copyright 2018 New Vector Ltd
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
properties:
|
||||||
|
events:
|
||||||
|
description: List of events.
|
||||||
|
items:
|
||||||
|
allOf:
|
||||||
|
- $ref: event-schemas/schema/core-event-schema/sync_state_event.yaml
|
||||||
|
type: object
|
||||||
|
required:
|
||||||
|
- event_id
|
||||||
|
#- room_id - Not in /sync
|
||||||
|
- sender
|
||||||
|
- origin_server_ts
|
||||||
|
- state_key
|
||||||
|
type: array
|
||||||
|
type: object
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
# Copyright 2016 OpenMarket Ltd
|
# Copyright 2016 OpenMarket Ltd
|
||||||
|
# Copyright 2018 New Vector Ltd
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
|
|
@ -12,14 +13,14 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
allOf:
|
allOf:
|
||||||
- $ref: event_batch.yaml
|
- $ref: room_event_batch.yaml
|
||||||
properties:
|
properties:
|
||||||
limited:
|
limited:
|
||||||
description: True if the number of events returned was limited by the ``limit``
|
description: True if the number of events returned was limited by the ``limit``
|
||||||
on the filter
|
on the filter.
|
||||||
type: boolean
|
type: boolean
|
||||||
prev_batch:
|
prev_batch:
|
||||||
description: A token that can be supplied to the ``from`` parameter of the
|
description: A token that can be supplied to the ``from`` parameter of the
|
||||||
rooms/{roomId}/messages endpoint
|
rooms/{roomId}/messages endpoint.
|
||||||
type: string
|
type: string
|
||||||
type: object
|
type: object
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@ paths:
|
||||||
``timeline``, if ``since`` is not given, or
|
``timeline``, if ``since`` is not given, or
|
||||||
``full_state`` is true).
|
``full_state`` is true).
|
||||||
allOf:
|
allOf:
|
||||||
- $ref: "definitions/event_batch.yaml"
|
- $ref: "definitions/state_event_batch.yaml"
|
||||||
timeline:
|
timeline:
|
||||||
title: Timeline
|
title: Timeline
|
||||||
type: object
|
type: object
|
||||||
|
|
@ -202,7 +202,7 @@ paths:
|
||||||
delta against the archived ``state`` not the
|
delta against the archived ``state`` not the
|
||||||
``invite_state``.
|
``invite_state``.
|
||||||
allOf:
|
allOf:
|
||||||
- $ref: "definitions/event_batch.yaml"
|
- $ref: "definitions/state_event_batch.yaml"
|
||||||
leave:
|
leave:
|
||||||
title: Left rooms
|
title: Left rooms
|
||||||
type: object
|
type: object
|
||||||
|
|
@ -218,7 +218,7 @@ paths:
|
||||||
description: |-
|
description: |-
|
||||||
The state updates for the room up to the start of the timeline.
|
The state updates for the room up to the start of the timeline.
|
||||||
allOf:
|
allOf:
|
||||||
- $ref: "definitions/event_batch.yaml"
|
- $ref: "definitions/state_event_batch.yaml"
|
||||||
timeline:
|
timeline:
|
||||||
title: Timeline
|
title: Timeline
|
||||||
type: object
|
type: object
|
||||||
|
|
@ -261,6 +261,8 @@ paths:
|
||||||
description: |-
|
description: |-
|
||||||
Information on end-to-end encryption keys, as specified
|
Information on end-to-end encryption keys, as specified
|
||||||
in |device_lists_sync|_.
|
in |device_lists_sync|_.
|
||||||
|
required:
|
||||||
|
- next_batch
|
||||||
examples:
|
examples:
|
||||||
application/json: {
|
application/json: {
|
||||||
"next_batch": "s72595_4483_1934",
|
"next_batch": "s72595_4483_1934",
|
||||||
|
|
@ -312,7 +314,6 @@ paths:
|
||||||
{
|
{
|
||||||
"sender": "@alice:example.com",
|
"sender": "@alice:example.com",
|
||||||
"type": "m.room.message",
|
"type": "m.room.message",
|
||||||
"age": 124524,
|
|
||||||
"txn_id": "1234",
|
"txn_id": "1234",
|
||||||
"content": {
|
"content": {
|
||||||
"body": "I am a fish",
|
"body": "I am a fish",
|
||||||
|
|
|
||||||
|
|
@ -10,5 +10,6 @@ properties:
|
||||||
type: string
|
type: string
|
||||||
required:
|
required:
|
||||||
- type
|
- type
|
||||||
|
- content
|
||||||
title: Event
|
title: Event
|
||||||
type: object
|
type: object
|
||||||
|
|
|
||||||
|
|
@ -1,45 +1,14 @@
|
||||||
allOf:
|
allOf:
|
||||||
- $ref: event.yaml
|
- $ref: sync_room_event.yaml
|
||||||
description: In addition to the Event fields, Room Events have the following additional
|
description: In addition to the Event fields, Room Events have the following additional
|
||||||
fields.
|
fields.
|
||||||
properties:
|
properties:
|
||||||
event_id:
|
|
||||||
description: The globally unique event identifier.
|
|
||||||
type: string
|
|
||||||
room_id:
|
room_id:
|
||||||
description: The ID of the room associated with this event.
|
description: |-
|
||||||
|
The ID of the room associated with this event. Will not be present on events
|
||||||
|
that arrive through ``/sync``, despite being required everywhere else.
|
||||||
type: string
|
type: string
|
||||||
sender:
|
|
||||||
description: Contains the fully-qualified ID of the user who *sent*
|
|
||||||
this event.
|
|
||||||
type: string
|
|
||||||
origin_server_ts:
|
|
||||||
description: Timestamp in milliseconds on originating homeserver
|
|
||||||
when this event was sent.
|
|
||||||
type: number
|
|
||||||
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
|
|
||||||
required:
|
required:
|
||||||
- event_id
|
|
||||||
- room_id
|
- room_id
|
||||||
- sender
|
|
||||||
- origin_server_ts
|
|
||||||
title: Room Event
|
title: Room Event
|
||||||
type: object
|
type: object
|
||||||
|
|
|
||||||
60
event-schemas/schema/core-event-schema/sync_room_event.yaml
Normal file
60
event-schemas/schema/core-event-schema/sync_room_event.yaml
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
# Copyright 2018 New Vector Ltd
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
# Note: this is technically not a core event schema, however it is included here
|
||||||
|
# to keep things sane. The short story is that /sync doesn't require a room_id to
|
||||||
|
# be on events, so we give it a whole event structure as a base for room_event.
|
||||||
|
# This base doesn't declare a room_id, which instead appears in the room_event.
|
||||||
|
|
||||||
|
allOf:
|
||||||
|
- $ref: event.yaml
|
||||||
|
description: In addition to the Event fields, Room Events have the following additional
|
||||||
|
fields.
|
||||||
|
properties:
|
||||||
|
event_id:
|
||||||
|
description: The globally unique event identifier.
|
||||||
|
type: string
|
||||||
|
sender:
|
||||||
|
description: Contains the fully-qualified ID of the user who *sent*
|
||||||
|
this event.
|
||||||
|
type: string
|
||||||
|
origin_server_ts:
|
||||||
|
description: Timestamp in milliseconds on originating homeserver
|
||||||
|
when this event was sent.
|
||||||
|
type: number
|
||||||
|
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
|
||||||
|
required:
|
||||||
|
- event_id
|
||||||
|
- sender
|
||||||
|
- origin_server_ts
|
||||||
|
title: Room Event
|
||||||
|
type: object
|
||||||
35
event-schemas/schema/core-event-schema/sync_state_event.yaml
Normal file
35
event-schemas/schema/core-event-schema/sync_state_event.yaml
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
# Copyright 2018 New Vector Ltd
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
# See sync_room_event.yaml for why this file is here.
|
||||||
|
|
||||||
|
allOf:
|
||||||
|
- $ref: sync_room_event.yaml
|
||||||
|
description: In addition to the Room Event fields, State Events have the following
|
||||||
|
additional fields.
|
||||||
|
properties:
|
||||||
|
prev_content:
|
||||||
|
description: Optional. The previous ``content`` for this event. If there is no
|
||||||
|
previous content, this key will be missing.
|
||||||
|
title: EventContent
|
||||||
|
type: object
|
||||||
|
state_key:
|
||||||
|
description: A unique key which defines the overwriting semantics for this piece
|
||||||
|
of room state. This value is often a zero-length string. The presence of this
|
||||||
|
key makes this event a State Event. The key MUST NOT start with '_'.
|
||||||
|
type: string
|
||||||
|
required:
|
||||||
|
- state_key
|
||||||
|
title: State Event
|
||||||
|
type: object
|
||||||
Loading…
Reference in a new issue