From 5216b1ac8a1063b0394cddada401985d69963f91 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Mon, 18 May 2015 16:52:03 +0100 Subject: [PATCH] Add m.room.topic. Add title/descs. Add 'type' key checking. --- event-schemas/examples/m.room.topic | 12 ++++++++++++ event-schemas/schema/core | 22 ++++++++++++++++++---- event-schemas/schema/m.room.message | 4 ++++ event-schemas/schema/m.room.name | 4 ++++ event-schemas/schema/m.room.topic | 26 ++++++++++++++++++++++++++ 5 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 event-schemas/examples/m.room.topic create mode 100644 event-schemas/schema/m.room.topic diff --git a/event-schemas/examples/m.room.topic b/event-schemas/examples/m.room.topic new file mode 100644 index 00000000..8a469122 --- /dev/null +++ b/event-schemas/examples/m.room.topic @@ -0,0 +1,12 @@ +{ + "age": 242352, + "content": { + "topic": "A room topic" + }, + "state_key": "", + "origin_server_ts": 1431961217939, + "event_id": "$WLGTSEFSEF:localhost", + "type": "m.room.topic", + "room_id": "!Cuyf34gef24t:localhost", + "user_id": "@example:localhost" +} diff --git a/event-schemas/schema/core b/event-schemas/schema/core index 277ff768..11d931d5 100644 --- a/event-schemas/schema/core +++ b/event-schemas/schema/core @@ -2,25 +2,32 @@ "$schema": "http://json-schema.org/draft-04/schema#", "definitions": { "event": { + "title": "Event", + "description": "The basic set of fields all events must have.", "type": "object", "properties": { "event_id": { - "type": "string" + "type": "string", + "description": "The globally unique event identifier." }, "user_id": { "type": "string" }, "content": { - "type": "object" + "type": "object", + "description": "The fields in this object will vary depending on the type of event." }, "type": { - "type": "string" + "type": "string", + "description": "The type of event. This SHOULD be namespaced similar to Java package naming conventions e.g. 'com.example.subdomain.event.type'" } }, "required": ["event_id", "user_id", "content", "type"] }, "room_event": { "type": "object", + "title": "Room Event", + "description": "The basic set of fields all room events must have.", "allOf":[{ "$ref": "#/definitions/event" }], @@ -33,12 +40,19 @@ }, "state_event": { "type": "object", + "title": "State Event", + "description": "The basic set of fields which define a room state event.", "allOf":[{ "$ref": "#/definitions/room_event" }], "properties": { "state_key": { - "type": "string" + "type": "string", + "description": "A unique key which defines the overwriting semantics for this piece of room state. This value is often a 0-length string." + }, + "prev_content": { + "type": "object", + "description": "The previous content if this event has overwritten another event." } }, "required": ["state_key"] diff --git a/event-schemas/schema/m.room.message b/event-schemas/schema/m.room.message index 0b22ca9d..2b00dfd0 100644 --- a/event-schemas/schema/m.room.message +++ b/event-schemas/schema/m.room.message @@ -16,6 +16,10 @@ } }, "required": ["msgtype", "body"] + }, + "type": { + "type": "string", + "enum": ["m.room.message"] } } } diff --git a/event-schemas/schema/m.room.name b/event-schemas/schema/m.room.name index bfcd509b..6dca3b14 100644 --- a/event-schemas/schema/m.room.name +++ b/event-schemas/schema/m.room.name @@ -17,6 +17,10 @@ "state_key": { "type": "string", "pattern": "^$" + }, + "type": { + "type": "string", + "enum": ["m.room.name"] } } } diff --git a/event-schemas/schema/m.room.topic b/event-schemas/schema/m.room.topic new file mode 100644 index 00000000..80ae1191 --- /dev/null +++ b/event-schemas/schema/m.room.topic @@ -0,0 +1,26 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "allOf": [{ + "$ref": "core#/definitions/state_event" + }], + "properties": { + "content": { + "type": "object", + "properties": { + "topic": { + "type": "string" + } + }, + "required": ["topic"] + }, + "state_key": { + "type": "string", + "pattern": "^$" + }, + "type": { + "type": "string", + "enum": ["m.room.topic"] + } + } +}