From 59168df363f3c2a597a10f96c70c6673a2cc4afb Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Wed, 27 May 2015 15:32:22 +0100 Subject: [PATCH] Add schema/example files for all specced msgtypes. --- .../examples/v1/m.room.message#m.audio | 18 ++++ .../examples/v1/m.room.message#m.file | 18 ++++ .../examples/v1/m.room.message#m.location | 20 +++++ .../examples/v1/m.room.message#m.video | 27 ++++++ .../schema/v1/m.room.message#m.audio | 52 ++++++++++++ .../schema/v1/m.room.message#m.emote | 29 +++++++ event-schemas/schema/v1/m.room.message#m.file | 79 ++++++++++++++++++ .../schema/v1/m.room.message#m.image | 83 +++++++++++++++++++ .../schema/v1/m.room.message#m.location | 41 +++++++++ .../schema/v1/m.room.message#m.notice | 29 +++++++ event-schemas/schema/v1/m.room.message#m.text | 29 +++++++ .../schema/v1/m.room.message#m.video | 68 +++++++++++++++ 12 files changed, 493 insertions(+) create mode 100644 event-schemas/examples/v1/m.room.message#m.audio create mode 100644 event-schemas/examples/v1/m.room.message#m.file create mode 100644 event-schemas/examples/v1/m.room.message#m.location create mode 100644 event-schemas/examples/v1/m.room.message#m.video create mode 100644 event-schemas/schema/v1/m.room.message#m.audio create mode 100644 event-schemas/schema/v1/m.room.message#m.emote create mode 100644 event-schemas/schema/v1/m.room.message#m.file create mode 100644 event-schemas/schema/v1/m.room.message#m.image create mode 100644 event-schemas/schema/v1/m.room.message#m.location create mode 100644 event-schemas/schema/v1/m.room.message#m.notice create mode 100644 event-schemas/schema/v1/m.room.message#m.text create mode 100644 event-schemas/schema/v1/m.room.message#m.video diff --git a/event-schemas/examples/v1/m.room.message#m.audio b/event-schemas/examples/v1/m.room.message#m.audio new file mode 100644 index 00000000..b57adc9a --- /dev/null +++ b/event-schemas/examples/v1/m.room.message#m.audio @@ -0,0 +1,18 @@ +{ + "age": 146, + "content": { + "body": "Bee Gees - Stayin' Alive", + "url": "mxc://localhost/ffed755USFFxlgbQYZGtryd", + "info": { + "duration": 2140786, + "size": 1563685, + "mimetype": "audio/mpeg" + }, + "msgtype": "m.audio" + }, + "event_id": "$143273582443PhrSn:localhost", + "origin_server_ts": 1432735824653, + "room_id": "!jEsUZKDJdhlrceRyVU:localhost", + "type": "m.room.message", + "user_id": "@example:localhost" +} \ No newline at end of file diff --git a/event-schemas/examples/v1/m.room.message#m.file b/event-schemas/examples/v1/m.room.message#m.file new file mode 100644 index 00000000..7ac36c90 --- /dev/null +++ b/event-schemas/examples/v1/m.room.message#m.file @@ -0,0 +1,18 @@ +{ + "age": 146, + "content": { + "body": "something-important.doc", + "filename": "something-important.doc", + "info": { + "mimetype": "application/msword", + "size": 46144 + }, + "msgtype": "m.file", + "url": "mxc://localhost/FHyPlCeYUSFFxlgbQYZmoEoe" + }, + "event_id": "$143273582443PhrSn:localhost", + "origin_server_ts": 1432735824653, + "room_id": "!jEsUZKDJdhlrceRyVU:localhost", + "type": "m.room.message", + "user_id": "@example:localhost" +} \ No newline at end of file diff --git a/event-schemas/examples/v1/m.room.message#m.location b/event-schemas/examples/v1/m.room.message#m.location new file mode 100644 index 00000000..b192b832 --- /dev/null +++ b/event-schemas/examples/v1/m.room.message#m.location @@ -0,0 +1,20 @@ +{ + "age": 146, + "content": { + "body": "Big Ben, London, UK", + "geo_uri": "geo:51.5008,0.1247", + "thumbnail_url": "mxc://localhost/FHyPlCeYUSFFxlgbQYZmoEoe", + "thumbnail_info": { + "mimetype": "image/jpeg", + "size": 46144, + "w": 300, + "h": 300 + }, + "msgtype": "m.location" + }, + "event_id": "$143273582443PhrSn:localhost", + "origin_server_ts": 1432735824653, + "room_id": "!jEsUZKDJdhlrceRyVU:localhost", + "type": "m.room.message", + "user_id": "@example:localhost" +} \ No newline at end of file diff --git a/event-schemas/examples/v1/m.room.message#m.video b/event-schemas/examples/v1/m.room.message#m.video new file mode 100644 index 00000000..e3da9077 --- /dev/null +++ b/event-schemas/examples/v1/m.room.message#m.video @@ -0,0 +1,27 @@ +{ + "age": 146, + "content": { + "body": "Gangnam Style", + "url": "mxc://localhost/a526eYUSFFxlgbQYZmo442", + "info": { + "thumbnail_url": "mxc://localhost/FHyPlCeYUSFFxlgbQYZmoEoe", + "thumbnail_info": { + "mimetype": "image/jpeg", + "size": 46144, + "w": 300, + "h": 300 + }, + "w": 480, + "h": 320, + "duration": 2140786, + "size": 1563685, + "mimetype": "video/mp4" + }, + "msgtype": "m.video" + }, + "event_id": "$143273582443PhrSn:localhost", + "origin_server_ts": 1432735824653, + "room_id": "!jEsUZKDJdhlrceRyVU:localhost", + "type": "m.room.message", + "user_id": "@example:localhost" +} \ No newline at end of file diff --git a/event-schemas/schema/v1/m.room.message#m.audio b/event-schemas/schema/v1/m.room.message#m.audio new file mode 100644 index 00000000..9910cb0c --- /dev/null +++ b/event-schemas/schema/v1/m.room.message#m.audio @@ -0,0 +1,52 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "title": "AudioMessage", + "description": "This message represents a single audio clip.", + "allOf": [{ + "$ref": "core#/definitions/room_event" + }], + "properties": { + "content": { + "type": "object", + "properties": { + "msgtype": { + "type": "string", + "enum": ["m.audio"] + }, + "body": { + "type": "string", + "description": "A description of the audio e.g. 'Bee Gees - Stayin' Alive', or some kind of content description for accessibility e.g. 'audio attachment'." + }, + "url": { + "type": "string", + "description": "The URL to the audio clip." + }, + "info": { + "type": "object", + "title": "AudioInfo", + "description": "Metadata for the audio clip referred to in ``url``.", + "properties": { + "mimetype": { + "type": "string", + "description": "The mimetype of the audio e.g. ``audio/aac``." + }, + "size": { + "type": "integer", + "description": "The size of the audio clip in bytes." + }, + "duration": { + "type": "integer", + "description": "The duration of the audio in milliseconds." + } + } + } + }, + "required": ["msgtype", "body", "url"] + }, + "type": { + "type": "string", + "enum": ["m.room.message"] + } + } +} diff --git a/event-schemas/schema/v1/m.room.message#m.emote b/event-schemas/schema/v1/m.room.message#m.emote new file mode 100644 index 00000000..886abafc --- /dev/null +++ b/event-schemas/schema/v1/m.room.message#m.emote @@ -0,0 +1,29 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "title": "EmoteMessage", + "description": "This message is similar to ``m.text`` except that the sender is 'performing' the action contained in the ``body`` key, similar to ``/me`` in IRC. This message should be prefixed by the name of the sender. This message could also be represented in a different colour to distinguish it from regular ``m.text`` messages.", + "allOf": [{ + "$ref": "core#/definitions/room_event" + }], + "properties": { + "content": { + "type": "object", + "properties": { + "msgtype": { + "type": "string", + "enum": ["m.emote"] + }, + "body": { + "type": "string", + "description": "The emote action to perform." + } + }, + "required": ["msgtype", "body"] + }, + "type": { + "type": "string", + "enum": ["m.room.message"] + } + } +} diff --git a/event-schemas/schema/v1/m.room.message#m.file b/event-schemas/schema/v1/m.room.message#m.file new file mode 100644 index 00000000..c07f17b3 --- /dev/null +++ b/event-schemas/schema/v1/m.room.message#m.file @@ -0,0 +1,79 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "title": "FileMessage", + "description": "TODO.", + "allOf": [{ + "$ref": "core#/definitions/room_event" + }], + "properties": { + "content": { + "type": "object", + "properties": { + "msgtype": { + "type": "string", + "enum": ["m.file"] + }, + "filename": { + "type": "string", + "description": "The original filename of the uploaded file." + }, + "body": { + "type": "string", + "description": "A human-readable description of the file. This is recommended to be the filename of the original upload." + }, + "url": { + "type": "string", + "description": "The URL to the file." + }, + "info": { + "type": "object", + "title": "FileInfo", + "description": "Information about the file referred to in ``url``.", + "properties": { + "size": { + "type": "integer", + "description": "The size of the file in bytes." + }, + "mimetype": { + "type": "string", + "description": "The mimetype of the file e.g. ``application/msword``." + } + } + }, + "thumbnail_url": { + "type": "string", + "description": "The URL to the thumbnail of the file." + }, + "thumbnail_info": { + "type": "object", + "title": "ImageInfo", + "description": "Metadata about the image referred to in ``thumbnail_url``.", + "properties": { + "size": { + "type": "integer", + "description": "Size of the image in bytes." + }, + "w": { + "type": "integer", + "description": "The width of the image in pixels." + }, + "h": { + "type": "integer", + "description": "The height of the image in pixels." + }, + "mimetype": { + "type": "string", + "description": "The mimetype of the image, e.g. ``image/jpeg``." + } + } + } + }, + "required": ["msgtype", "body", "url", "filename"] + }, + "type": { + "type": "string", + "enum": ["m.room.message"] + } + } +} diff --git a/event-schemas/schema/v1/m.room.message#m.image b/event-schemas/schema/v1/m.room.message#m.image new file mode 100644 index 00000000..29552452 --- /dev/null +++ b/event-schemas/schema/v1/m.room.message#m.image @@ -0,0 +1,83 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "title": "ImageMessage", + "description": "This message represents a single image and an optional thumbnail.", + "allOf": [{ + "$ref": "core#/definitions/room_event" + }], + "properties": { + "content": { + "type": "object", + "properties": { + "msgtype": { + "type": "string", + "enum": ["m.image"] + }, + "body": { + "type": "string", + "description": "A textual representation of the image. This could be the alt text of the image, the filename of the image, or some kind of content description for accessibility e.g. 'image attachment'." + }, + "url": { + "type": "string", + "description": "The URL to the image." + }, + "thumbnail_url": { + "type": "string", + "description": "The URL to the thumbnail of the image." + }, + "thumbnail_info": { + "type": "object", + "title": "ImageInfo", + "description": "Metadata about the image referred to in ``thumbnail_url``.", + "properties": { + "size": { + "type": "integer", + "description": "Size of the image in bytes." + }, + "w": { + "type": "integer", + "description": "The width of the image in pixels." + }, + "h": { + "type": "integer", + "description": "The height of the image in pixels." + }, + "mimetype": { + "type": "string", + "description": "The mimetype of the image, e.g. ``image/jpeg``." + } + } + }, + "info": { + "type": "object", + "title": "ImageInfo", + "description": "Metadata about the image referred to in ``url``.", + "properties": { + "size": { + "type": "integer", + "description": "Size of the image in bytes." + }, + "w": { + "type": "integer", + "description": "The width of the image in pixels." + }, + "h": { + "type": "integer", + "description": "The height of the image in pixels." + }, + "mimetype": { + "type": "string", + "description": "The mimetype of the image, e.g. ``image/jpeg``." + } + } + } + }, + "required": ["msgtype", "body", "url"] + }, + "type": { + "type": "string", + "enum": ["m.room.message"] + } + } +} diff --git a/event-schemas/schema/v1/m.room.message#m.location b/event-schemas/schema/v1/m.room.message#m.location new file mode 100644 index 00000000..d1b95157 --- /dev/null +++ b/event-schemas/schema/v1/m.room.message#m.location @@ -0,0 +1,41 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "title": "LocationMessage", + "description": "This message represents a real-world location.", + "allOf": [{ + "$ref": "core#/definitions/room_event" + }], + "properties": { + "content": { + "type": "object", + "properties": { + "msgtype": { + "type": "string", + "enum": ["m.location"] + }, + "body": { + "type": "string", + "description": "A description of the location e.g. 'Big Ben, London, UK', or some kind of content description for accessibility e.g. 'location attachment'." + }, + "geo_uri": { + "type": "string", + "description": "A geo URI representing this location." + }, + "thumbnail_url": { + "type": "string", + "description": "The URL to a thumbnail of the location being represented." + }, + "thumbnail_info": { + "type": "object", + "title": "ImageInfo" + } + }, + "required": ["msgtype", "body", "geo_uri"] + }, + "type": { + "type": "string", + "enum": ["m.room.message"] + } + } +} diff --git a/event-schemas/schema/v1/m.room.message#m.notice b/event-schemas/schema/v1/m.room.message#m.notice new file mode 100644 index 00000000..0f8044f5 --- /dev/null +++ b/event-schemas/schema/v1/m.room.message#m.notice @@ -0,0 +1,29 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "title": "NoticeMessage", + "description": "A m.notice message should be considered similar to a plain m.text message except that clients should visually distinguish it in some way. It is intended to be used by automated clients, such as bots, bridges, and other entities, rather than humans. Additionally, such automated agents which watch a room for messages and respond to them ought to ignore m.notice messages. This helps to prevent infinite-loop situations where two automated clients continuously exchange messages, as each responds to the other.", + "allOf": [{ + "$ref": "core#/definitions/room_event" + }], + "properties": { + "content": { + "type": "object", + "properties": { + "msgtype": { + "type": "string", + "enum": ["m.notice"] + }, + "body": { + "type": "string", + "description": "The notice text to send." + } + }, + "required": ["msgtype", "body"] + }, + "type": { + "type": "string", + "enum": ["m.room.message"] + } + } +} diff --git a/event-schemas/schema/v1/m.room.message#m.text b/event-schemas/schema/v1/m.room.message#m.text new file mode 100644 index 00000000..054d4a96 --- /dev/null +++ b/event-schemas/schema/v1/m.room.message#m.text @@ -0,0 +1,29 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "title": "TextMessage", + "description": "This message is the most basic message and is used to represent text.", + "allOf": [{ + "$ref": "core#/definitions/room_event" + }], + "properties": { + "content": { + "type": "object", + "properties": { + "msgtype": { + "type": "string", + "enum": ["m.text"] + }, + "body": { + "type": "string", + "description": "The body of the message." + } + }, + "required": ["msgtype", "body"] + }, + "type": { + "type": "string", + "enum": ["m.room.message"] + } + } +} diff --git a/event-schemas/schema/v1/m.room.message#m.video b/event-schemas/schema/v1/m.room.message#m.video new file mode 100644 index 00000000..960126b8 --- /dev/null +++ b/event-schemas/schema/v1/m.room.message#m.video @@ -0,0 +1,68 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "title": "VideoMessage", + "description": "This message represents a single video clip.", + "allOf": [{ + "$ref": "core#/definitions/room_event" + }], + "properties": { + "content": { + "type": "object", + "properties": { + "msgtype": { + "type": "string", + "enum": ["m.video"] + }, + "body": { + "type": "string", + "description": "A description of the video e.g. 'Gangnam style', or some kind of content description for accessibility e.g. 'video attachment'." + }, + "url": { + "type": "string", + "description": "The URL to the video clip." + }, + "info": { + "type": "object", + "title": "VideoInfo", + "description": "Metadata about the video clip referred to in ``url``.", + "properties": { + "mimetype": { + "type": "string", + "description": "The mimetype of the video e.g. ``video/mp4``." + }, + "size": { + "type": "integer", + "description": "The size of the video in bytes." + }, + "duration": { + "type": "integer", + "description": "The duration of the video in milliseconds." + }, + "w": { + "type": "integer", + "description": "The width of the video in pixels." + }, + "h": { + "type": "integer", + "description": "The height of the video in pixels." + }, + "thumbnail_url": { + "type": "string", + "description": "The URL to a thumbnail of the video clip." + }, + "thumbnail_info": { + "type": "object", + "title": "ImageInfo" + } + } + } + }, + "required": ["msgtype", "body", "url"] + }, + "type": { + "type": "string", + "enum": ["m.room.message"] + } + } +}