diff --git a/changelogs/client_server/newsfragments/1558.clarification b/changelogs/client_server/newsfragments/1558.clarification
new file mode 100644
index 000000000..3482d89cc
--- /dev/null
+++ b/changelogs/client_server/newsfragments/1558.clarification
@@ -0,0 +1 @@
+Update all event examples to be accurate representations of their associated events.
diff --git a/event-schemas/check_examples.py b/event-schemas/check_examples.py
index f2456d97e..3e536ec3b 100755
--- a/event-schemas/check_examples.py
+++ b/event-schemas/check_examples.py
@@ -44,16 +44,51 @@ except ImportError as e:
raise
+def load_file(path):
+ print("Loading reference: %s" % path)
+ if not path.startswith("file://"):
+ raise Exception("Bad ref: %s" % (path,))
+ path = path[len("file://"):]
+ with open(path, "r") as f:
+ if path.endswith(".json"):
+ return json.load(f)
+ else:
+ # We have to assume it's YAML because some of the YAML examples
+ # do not have file extensions.
+ return yaml.load(f)
+
+
+def resolve_references(path, schema):
+ if isinstance(schema, dict):
+ # do $ref first
+ if '$ref' in schema:
+ value = schema['$ref']
+ path = os.path.abspath(os.path.join(os.path.dirname(path), value))
+ ref = load_file("file://" + path)
+ result = resolve_references(path, ref)
+ del schema['$ref']
+ else:
+ result = {}
+
+ for key, value in schema.items():
+ result[key] = resolve_references(path, value)
+ return result
+ elif isinstance(schema, list):
+ return [resolve_references(path, value) for value in schema]
+ else:
+ return schema
+
+
def check_example_file(examplepath, schemapath):
with open(examplepath) as f:
- example = yaml.load(f)
+ example = resolve_references(examplepath, json.load(f))
with open(schemapath) as f:
schema = yaml.load(f)
fileurl = "file://" + os.path.abspath(schemapath)
schema["id"] = fileurl
- resolver = jsonschema.RefResolver(schemapath, schema, handlers={"file": load_yaml})
+ resolver = jsonschema.RefResolver(schemapath, schema, handlers={"file": load_file})
print ("Checking schema for: %r %r" % (examplepath, schemapath))
try:
@@ -71,6 +106,10 @@ def check_example_dir(exampledir, schemadir):
if filename.startswith("."):
# Skip over any vim .swp files.
continue
+ cwd = os.path.basename(os.path.dirname(os.path.join(root, filename)))
+ if cwd == "core":
+ # Skip checking the underlying definitions
+ continue
examplepath = os.path.join(root, filename)
schemapath = examplepath.replace(exampledir, schemadir)
if schemapath.find("#") >= 0:
@@ -85,14 +124,6 @@ def check_example_dir(exampledir, schemadir):
raise ValueError("Error validating examples")
-def load_yaml(path):
- if not path.startswith("file:///"):
- raise Exception("Bad ref: %s" % (path,))
- path = path[len("file://"):]
- with open(path, "r") as f:
- return yaml.load(f)
-
-
if __name__ == '__main__':
try:
check_example_dir("examples", "schema")
diff --git a/event-schemas/examples/core/event.json b/event-schemas/examples/core/event.json
new file mode 100644
index 000000000..8a469a5cb
--- /dev/null
+++ b/event-schemas/examples/core/event.json
@@ -0,0 +1,6 @@
+{
+ "content": {
+ "key": "value"
+ },
+ "type": "org.example.custom.event"
+}
diff --git a/event-schemas/examples/core/room_edu.json b/event-schemas/examples/core/room_edu.json
new file mode 100644
index 000000000..80575f5d7
--- /dev/null
+++ b/event-schemas/examples/core/room_edu.json
@@ -0,0 +1,4 @@
+{
+ "$ref": "event.json",
+ "room_id": "!jEsUZKDJdhlrceRyVU:domain.com"
+}
diff --git a/event-schemas/examples/core/room_event.json b/event-schemas/examples/core/room_event.json
new file mode 100644
index 000000000..41837afb5
--- /dev/null
+++ b/event-schemas/examples/core/room_event.json
@@ -0,0 +1,10 @@
+{
+ "$ref": "event.json",
+ "event_id": "$143273582443PhrSn:domain.com",
+ "room_id": "!jEsUZKDJdhlrceRyVU:domain.com",
+ "sender": "@example:domain.com",
+ "origin_server_ts": 1432735824653,
+ "unsigned": {
+ "age": 1234
+ }
+}
diff --git a/event-schemas/examples/core/state_event.json b/event-schemas/examples/core/state_event.json
new file mode 100644
index 000000000..910747ee2
--- /dev/null
+++ b/event-schemas/examples/core/state_event.json
@@ -0,0 +1,4 @@
+{
+ "$ref": "room_event.json",
+ "state_key": "ArbitraryString"
+}
diff --git a/event-schemas/examples/m.call.answer b/event-schemas/examples/m.call.answer
index f7d144394..a4cfc1e16 100644
--- a/event-schemas/examples/m.call.answer
+++ b/event-schemas/examples/m.call.answer
@@ -1,5 +1,6 @@
{
- "age": 242352,
+ "$ref": "core/room_event.json",
+ "type": "m.call.answer",
"content": {
"version" : 0,
"call_id": "12345",
@@ -8,10 +9,5 @@
"type" : "answer",
"sdp" : "v=0\r\no=- 6584580628695956864 2 IN IP4 127.0.0.1[...]"
}
- },
- "origin_server_ts": 1431961217939,
- "event_id": "$WLGTSEFSEF:localhost",
- "type": "m.call.answer",
- "room_id": "!Cuyf34gef24t:localhost",
- "sender": "@example:localhost"
+ }
}
diff --git a/event-schemas/examples/m.call.candidates b/event-schemas/examples/m.call.candidates
index 8e6849bb1..8f1f807ad 100644
--- a/event-schemas/examples/m.call.candidates
+++ b/event-schemas/examples/m.call.candidates
@@ -1,5 +1,6 @@
{
- "age": 242352,
+ "$ref": "core/room_event.json",
+ "type": "m.call.candidates",
"content": {
"version" : 0,
"call_id": "12345",
@@ -10,10 +11,5 @@
"candidate": "candidate:863018703 1 udp 2122260223 10.9.64.156 43670 typ host generation 0"
}
]
- },
- "origin_server_ts": 1431961217939,
- "event_id": "$WLGTSEFSEF:localhost",
- "type": "m.call.candidates",
- "room_id": "!Cuyf34gef24t:localhost",
- "sender": "@example:localhost"
+ }
}
diff --git a/event-schemas/examples/m.call.hangup b/event-schemas/examples/m.call.hangup
index 42e1f346c..295f16e48 100644
--- a/event-schemas/examples/m.call.hangup
+++ b/event-schemas/examples/m.call.hangup
@@ -1,12 +1,8 @@
{
- "age": 242352,
+ "$ref": "core/room_event.json",
+ "type": "m.call.hangup",
"content": {
"version" : 0,
"call_id": "12345"
- },
- "origin_server_ts": 1431961217939,
- "event_id": "$WLGTSEFSEF:localhost",
- "type": "m.call.hangup",
- "room_id": "!Cuyf34gef24t:localhost",
- "sender": "@example:localhost"
+ }
}
diff --git a/event-schemas/examples/m.call.invite b/event-schemas/examples/m.call.invite
index 974a5b4cd..fa482bd94 100644
--- a/event-schemas/examples/m.call.invite
+++ b/event-schemas/examples/m.call.invite
@@ -1,5 +1,6 @@
{
- "age": 242352,
+ "$ref": "core/room_event.json",
+ "type": "m.call.invite",
"content": {
"version" : 0,
"call_id": "12345",
@@ -8,10 +9,5 @@
"type" : "offer",
"sdp" : "v=0\r\no=- 6584580628695956864 2 IN IP4 127.0.0.1[...]"
}
- },
- "origin_server_ts": 1431961217939,
- "event_id": "$WLGTSEFSEF:localhost",
- "type": "m.call.invite",
- "room_id": "!Cuyf34gef24t:localhost",
- "sender": "@example:localhost"
+ }
}
diff --git a/event-schemas/examples/m.direct b/event-schemas/examples/m.direct
index 92f13daa2..e453dd599 100644
--- a/event-schemas/examples/m.direct
+++ b/event-schemas/examples/m.direct
@@ -1,9 +1,10 @@
{
+ "$ref": "core/event.json",
"type": "m.direct",
"content": {
"@bob:example.com": [
- "!abcdefgh:example.com",
- "!hgfedcba:example.com"
- ]
+ "!abcdefgh:example.com",
+ "!hgfedcba:example.com"
+ ]
}
}
diff --git a/event-schemas/examples/m.ignored_user_list b/event-schemas/examples/m.ignored_user_list
index f3a328f7f..9963d13aa 100644
--- a/event-schemas/examples/m.ignored_user_list
+++ b/event-schemas/examples/m.ignored_user_list
@@ -1,4 +1,5 @@
{
+ "$ref": "core/event.json",
"type": "m.ignored_user_list",
"content": {
"ignored_users": {
diff --git a/event-schemas/examples/m.presence b/event-schemas/examples/m.presence
index 824ffcb71..36093cd92 100644
--- a/event-schemas/examples/m.presence
+++ b/event-schemas/examples/m.presence
@@ -1,10 +1,11 @@
{
+ "$ref": "core/event.json",
+ "sender": "@example:localhost",
+ "type": "m.presence",
"content": {
"avatar_url": "mxc://localhost:wefuiwegh8742w",
"last_active_ago": 2478593,
"presence": "online",
"currently_active": false
- },
- "sender": "@example:localhost",
- "type": "m.presence"
+ }
}
diff --git a/event-schemas/examples/m.receipt b/event-schemas/examples/m.receipt
index bd0b726c3..c52d8540f 100644
--- a/event-schemas/examples/m.receipt
+++ b/event-schemas/examples/m.receipt
@@ -1,13 +1,13 @@
{
- "type": "m.receipt",
- "room_id": "!KpjVgQyZpzBwvMBsnT:matrix.org",
- "content": {
- "$1435641916114394fHBLK:matrix.org": {
- "m.read": {
- "@rikj:jki.re": {
- "ts": 1436451550453
- }
- }
+ "$ref": "core/room_edu.json",
+ "type": "m.receipt",
+ "content": {
+ "$1435641916114394fHBLK:matrix.org": {
+ "m.read": {
+ "@rikj:jki.re": {
+ "ts": 1436451550453
}
+ }
}
+ }
}
diff --git a/event-schemas/examples/m.room.aliases b/event-schemas/examples/m.room.aliases
index ca87510e3..bb2fe21c5 100644
--- a/event-schemas/examples/m.room.aliases
+++ b/event-schemas/examples/m.room.aliases
@@ -1,12 +1,8 @@
{
- "age": 242352,
- "content": {
- "aliases": ["#somewhere:localhost", "#another:localhost"]
- },
- "state_key": "localhost",
- "origin_server_ts": 1431961217939,
- "event_id": "$WLGTSEFSEF:localhost",
+ "$ref": "core/state_event.json",
+ "state_key": "domain.com",
"type": "m.room.aliases",
- "room_id": "!Cuyf34gef24t:localhost",
- "sender": "@example:localhost"
+ "content": {
+ "aliases": ["#somewhere:domain.com", "#another:domain.com"]
+ }
}
diff --git a/event-schemas/examples/m.room.avatar b/event-schemas/examples/m.room.avatar
index 2080d96ef..9b51e01fd 100644
--- a/event-schemas/examples/m.room.avatar
+++ b/event-schemas/examples/m.room.avatar
@@ -1,5 +1,7 @@
{
- "age": 242352,
+ "$ref": "core/state_event.json",
+ "type": "m.room.avatar",
+ "state_key": "",
"content": {
"info": {
"h": 398,
@@ -7,12 +9,6 @@
"mimetype": "image/jpeg",
"size": 31037
},
- "url": "mxc://localhost/JWEIFJgwEIhweiWJE"
- },
- "origin_server_ts": 1431961217939,
- "event_id": "$WLGTSEFSEF:localhost",
- "type": "m.room.avatar",
- "state_key": "",
- "room_id": "!Cuyf34gef24t:localhost",
- "sender": "@example:localhost"
+ "url": "mxc://domain.com/JWEIFJgwEIhweiWJE"
+ }
}
diff --git a/event-schemas/examples/m.room.canonical_alias b/event-schemas/examples/m.room.canonical_alias
index 59df586d9..06c3226c9 100644
--- a/event-schemas/examples/m.room.canonical_alias
+++ b/event-schemas/examples/m.room.canonical_alias
@@ -1,12 +1,8 @@
{
- "age": 242352,
+ "$ref": "core/state_event.json",
+ "type": "m.room.canonical_alias",
+ "state_key": "",
"content": {
"alias": "#somewhere:localhost"
- },
- "state_key": "",
- "origin_server_ts": 1431961217939,
- "event_id": "$WLGTSEFSEF:localhost",
- "type": "m.room.canonical_alias",
- "room_id": "!Cuyf34gef24t:localhost",
- "sender": "@example:localhost"
+ }
}
diff --git a/event-schemas/examples/m.room.create b/event-schemas/examples/m.room.create
index 34dabb536..181274977 100644
--- a/event-schemas/examples/m.room.create
+++ b/event-schemas/examples/m.room.create
@@ -1,12 +1,10 @@
{
- "age": 242352,
- "content": {
- "creator": "@example:localhost"
- },
- "state_key": "",
- "origin_server_ts": 1431961217939,
- "event_id": "$WLGTSEFSEF:localhost",
+ "$ref": "core/state_event.json",
"type": "m.room.create",
- "room_id": "!Cuyf34gef24t:localhost",
- "sender": "@example:localhost"
+ "state_key": "",
+ "content": {
+ "creator": "@example:domain.com",
+ "room_version": "1",
+ "m.federate": true
+ }
}
diff --git a/event-schemas/examples/m.room.encrypted#megolm b/event-schemas/examples/m.room.encrypted#megolm
index 1f9b75208..ac542e254 100644
--- a/event-schemas/examples/m.room.encrypted#megolm
+++ b/event-schemas/examples/m.room.encrypted#megolm
@@ -1,14 +1,11 @@
{
+ "$ref": "core/room_event.json",
+ "type": "m.room.encrypted",
"content": {
"algorithm": "m.megolm.v1.aes-sha2",
"ciphertext": "AwgAEnACgAkLmt6qF84IK++J7UDH2Za1YVchHyprqTqsg...",
"device_id": "RJYKSTBOIE",
"sender_key": "IlRMeOPX2e0MurIyfWEucYBRVOEEUMrOHqn/8mLqMjA",
"session_id": "X3lUlvLELLYxeTx4yOVu6UDpasGEVO0Jbu+QFnm0cKQ"
- },
- "event_id": "$WLGTSEFSEF:localhost",
- "room_id": "!Cuyf34gef24t:localhost",
- "origin_server_ts": 1476648761524,
- "sender": "@example:localhost",
- "type": "m.room.encrypted"
+ }
}
diff --git a/event-schemas/examples/m.room.encrypted#olm b/event-schemas/examples/m.room.encrypted#olm
index abb23c31e..381651d95 100644
--- a/event-schemas/examples/m.room.encrypted#olm
+++ b/event-schemas/examples/m.room.encrypted#olm
@@ -1,6 +1,6 @@
{
+ "$ref": "core/room_event.json",
"type": "m.room.encrypted",
- "sender": "@example:localhost",
"content": {
"algorithm": "m.olm.v1.curve25519-aes-sha2",
"sender_key": "Szl29ksW/L8yZGWAX+8dY1XyFi+i5wm+DRhTGkbMiwU",
diff --git a/event-schemas/examples/m.room.encryption b/event-schemas/examples/m.room.encryption
index 08f152396..6158b9379 100644
--- a/event-schemas/examples/m.room.encryption
+++ b/event-schemas/examples/m.room.encryption
@@ -1,13 +1,10 @@
{
+ "$ref": "core/state_event.json",
+ "type": "m.room.encryption",
+ "state_key": "",
"content": {
"algorithm": "m.megolm.v1.aes-sha2",
"rotation_period_ms": 604800000,
"rotation_period_msgs": 100
- },
- "event_id": "$WLGTSEFJJKJ:localhost",
- "origin_server_ts": 1476648761524,
- "sender": "@example:localhost",
- "room_id": "!Cuyf34gef24t:localhost",
- "state_key": "",
- "type": "m.room.encryption"
+ }
}
diff --git a/event-schemas/examples/m.room.guest_access b/event-schemas/examples/m.room.guest_access
index c636ff395..a6deff8c0 100644
--- a/event-schemas/examples/m.room.guest_access
+++ b/event-schemas/examples/m.room.guest_access
@@ -1,12 +1,8 @@
{
- "age": 242353,
+ "$ref": "core/state_event.json",
+ "type": "m.room.guest_access",
+ "state_key": "",
"content": {
"guest_access": "can_join"
- },
- "state_key": "",
- "origin_server_ts": 1431961217938,
- "event_id": "$WLGTSEFSEG:localhost",
- "type": "m.room.guest_access",
- "room_id": "!Cuyf34gef24u:localhost",
- "sender": "@example:localhost"
+ }
}
diff --git a/event-schemas/examples/m.room.history_visibility b/event-schemas/examples/m.room.history_visibility
index 6fedc5dc6..27c4fec35 100644
--- a/event-schemas/examples/m.room.history_visibility
+++ b/event-schemas/examples/m.room.history_visibility
@@ -1,12 +1,8 @@
{
- "age": 242352,
+ "$ref": "core/state_event.json",
+ "type": "m.room.history_visibility",
+ "state_key": "",
"content": {
"history_visibility": "shared"
- },
- "state_key": "",
- "origin_server_ts": 1431961217939,
- "event_id": "$WLGTSEFSEF:localhost",
- "type": "m.room.history_visibility",
- "room_id": "!Cuyf34gef24t:localhost",
- "sender": "@example:localhost"
+ }
}
diff --git a/event-schemas/examples/m.room.join_rules b/event-schemas/examples/m.room.join_rules
index 39e14fc5d..2873be781 100644
--- a/event-schemas/examples/m.room.join_rules
+++ b/event-schemas/examples/m.room.join_rules
@@ -1,12 +1,8 @@
{
- "age": 242352,
+ "$ref": "core/state_event.json",
+ "type": "m.room.join_rules",
+ "state_key": "",
"content": {
"join_rule": "public"
- },
- "state_key": "",
- "origin_server_ts": 1431961217939,
- "event_id": "$WLGTSEFSEF:localhost",
- "type": "m.room.join_rules",
- "room_id": "!Cuyf34gef24t:localhost",
- "sender": "@example:localhost"
+ }
}
diff --git a/event-schemas/examples/m.room.member b/event-schemas/examples/m.room.member
index 2495145ba..ce31ab8fe 100644
--- a/event-schemas/examples/m.room.member
+++ b/event-schemas/examples/m.room.member
@@ -1,14 +1,10 @@
{
- "age": 242352,
+ "$ref": "core/state_event.json",
+ "state_key": "@alice:domain.com",
+ "type": "m.room.member",
"content": {
"membership": "join",
- "avatar_url": "mxc://localhost/SEsfnsuifSDFSSEF#auto",
+ "avatar_url": "mxc://domain.com/SEsfnsuifSDFSSEF#auto",
"displayname": "Alice Margatroid"
- },
- "state_key": "@alice:localhost",
- "origin_server_ts": 1431961217939,
- "event_id": "$WLGTSEFSEF:localhost",
- "type": "m.room.member",
- "room_id": "!Cuyf34gef24t:localhost",
- "sender": "@example:localhost"
+ }
}
diff --git a/event-schemas/examples/m.room.member#invite_room_state b/event-schemas/examples/m.room.member#invite_room_state
index 965669adb..c99c66c0f 100644
--- a/event-schemas/examples/m.room.member#invite_room_state
+++ b/event-schemas/examples/m.room.member#invite_room_state
@@ -1,11 +1,12 @@
{
- "age": 242352,
+ "$ref": "m.room.member",
"content": {
"membership": "invite",
- "avatar_url": "mxc://localhost/SEsfnsuifSDFSSEF#auto",
+ "avatar_url": "mxc://domain.com/SEsfnsuifSDFSSEF#auto",
"displayname": "Alice Margatroid"
},
"unsigned": {
+ "age": 1234,
"invite_room_state": [
{
"type": "m.room.name",
@@ -22,11 +23,5 @@
}
}
]
- },
- "state_key": "@alice:localhost",
- "origin_server_ts": 1431961217939,
- "event_id": "$WLGTSEFSEF:localhost",
- "type": "m.room.member",
- "room_id": "!Cuyf34gef24t:localhost",
- "sender": "@example:localhost"
+ }
}
diff --git a/event-schemas/examples/m.room.member#third_party_invite b/event-schemas/examples/m.room.member#third_party_invite
index 244e15562..92b5d2ef9 100644
--- a/event-schemas/examples/m.room.member#third_party_invite
+++ b/event-schemas/examples/m.room.member#third_party_invite
@@ -1,13 +1,13 @@
{
- "age": 242352,
+ "$ref": "m.room.member",
"content": {
"membership": "invite",
- "avatar_url": "mxc://localhost/SEsfnsuifSDFSSEF#auto",
+ "avatar_url": "mxc://domain.com/SEsfnsuifSDFSSEF#auto",
"displayname": "Alice Margatroid",
"third_party_invite": {
"display_name": "alice",
"signed": {
- "mxid": "@alice:localhost",
+ "mxid": "@alice:domain.com",
"signatures": {
"magic.forest": {
"ed25519:3": "fQpGIW1Snz+pwLZu6sTy2aHy/DYWWTspTJRPyNp0PKkymfIsNffysMl6ObMMFdIJhk6g6pwlIqZ54rxo8SLmAg"
@@ -16,11 +16,5 @@
"token": "abc123"
}
}
- },
- "state_key": "@alice:localhost",
- "origin_server_ts": 1431961217939,
- "event_id": "$WLGTSEFSEF:localhost",
- "type": "m.room.member",
- "room_id": "!Cuyf34gef24t:localhost",
- "sender": "@example:localhost"
+ }
}
diff --git a/event-schemas/examples/m.room.message#m.audio b/event-schemas/examples/m.room.message#m.audio
index 367eb9540..4ce5a2a8a 100644
--- a/event-schemas/examples/m.room.message#m.audio
+++ b/event-schemas/examples/m.room.message#m.audio
@@ -1,18 +1,14 @@
{
- "age": 146,
+ "$ref": "core/room_event.json",
+ "type": "m.room.message",
"content": {
"body": "Bee Gees - Stayin' Alive",
- "url": "mxc://localhost/ffed755USFFxlgbQYZGtryd",
+ "url": "mxc://domain.com/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",
- "sender": "@example:localhost"
+ }
}
diff --git a/event-schemas/examples/m.room.message#m.emote b/event-schemas/examples/m.room.message#m.emote
index 79292ddf8..5fecb9a3f 100644
--- a/event-schemas/examples/m.room.message#m.emote
+++ b/event-schemas/examples/m.room.message#m.emote
@@ -1,14 +1,10 @@
{
- "age": 242352,
+ "$ref": "core/room_event.json",
+ "type": "m.room.message",
"content": {
"body": "thinks this is an example emote",
"msgtype": "m.emote",
"format": "org.matrix.custom.html",
"formatted_body": "thinks this is an example emote"
- },
- "origin_server_ts": 1431961217939,
- "event_id": "$WLGTSEFSEF:localhost",
- "type": "m.room.message",
- "room_id": "!Cuyf34gef24t:localhost",
- "sender": "@example:localhost"
+ }
}
diff --git a/event-schemas/examples/m.room.message#m.file b/event-schemas/examples/m.room.message#m.file
index e52c3a947..b518550aa 100644
--- a/event-schemas/examples/m.room.message#m.file
+++ b/event-schemas/examples/m.room.message#m.file
@@ -1,5 +1,6 @@
{
- "age": 146,
+ "$ref": "core/room_event.json",
+ "type": "m.room.message",
"content": {
"body": "something-important.doc",
"filename": "something-important.doc",
@@ -8,11 +9,6 @@
"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",
- "sender": "@example:localhost"
+ "url": "mxc://domain.com/FHyPlCeYUSFFxlgbQYZmoEoe"
+ }
}
diff --git a/event-schemas/examples/m.room.message#m.image b/event-schemas/examples/m.room.message#m.image
index 91e72be26..60402effc 100644
--- a/event-schemas/examples/m.room.message#m.image
+++ b/event-schemas/examples/m.room.message#m.image
@@ -1,5 +1,6 @@
{
- "age": 242352,
+ "$ref": "core/room_event.json",
+ "type": "m.room.message",
"content": {
"body": "filename.jpg",
"info": {
@@ -8,12 +9,7 @@
"mimetype": "image/jpeg",
"size": 31037
},
- "url": "mxc://localhost/JWEIFJgwEIhweiWJE",
+ "url": "mxc://domain.com/JWEIFJgwEIhweiWJE",
"msgtype": "m.image"
- },
- "origin_server_ts": 1431961217939,
- "event_id": "$WLGTSEFSEF:localhost",
- "type": "m.room.message",
- "room_id": "!Cuyf34gef24t:localhost",
- "sender": "@example:localhost"
+ }
}
diff --git a/event-schemas/examples/m.room.message#m.location b/event-schemas/examples/m.room.message#m.location
index 75363f6fd..1461a305d 100644
--- a/event-schemas/examples/m.room.message#m.location
+++ b/event-schemas/examples/m.room.message#m.location
@@ -1,10 +1,11 @@
{
- "age": 146,
+ "$ref": "core/room_event.json",
+ "type": "m.room.message",
"content": {
"body": "Big Ben, London, UK",
"geo_uri": "geo:51.5008,0.1247",
"info": {
- "thumbnail_url": "mxc://localhost/FHyPlCeYUSFFxlgbQYZmoEoe",
+ "thumbnail_url": "mxc://domain.com/FHyPlCeYUSFFxlgbQYZmoEoe",
"thumbnail_info": {
"mimetype": "image/jpeg",
"size": 46144,
@@ -13,10 +14,5 @@
}
},
"msgtype": "m.location"
- },
- "event_id": "$143273582443PhrSn:localhost",
- "origin_server_ts": 1432735824653,
- "room_id": "!jEsUZKDJdhlrceRyVU:localhost",
- "type": "m.room.message",
- "sender": "@example:localhost"
+ }
}
diff --git a/event-schemas/examples/m.room.message#m.notice b/event-schemas/examples/m.room.message#m.notice
index 876cbbb7d..d33751da3 100644
--- a/event-schemas/examples/m.room.message#m.notice
+++ b/event-schemas/examples/m.room.message#m.notice
@@ -1,14 +1,10 @@
{
- "age": 242352,
+ "$ref": "core/room_event.json",
+ "type": "m.room.message",
"content": {
"body": "This is an example notice",
"msgtype": "m.notice",
"format": "org.matrix.custom.html",
"formatted_body": "This is an example notice"
- },
- "origin_server_ts": 1431961217939,
- "event_id": "$WLGTSEFSEF:localhost",
- "type": "m.room.message",
- "room_id": "!Cuyf34gef24t:localhost",
- "sender": "@example:localhost"
+ }
}
diff --git a/event-schemas/examples/m.room.message#m.text b/event-schemas/examples/m.room.message#m.text
index 48a97db80..ba1fb7697 100644
--- a/event-schemas/examples/m.room.message#m.text
+++ b/event-schemas/examples/m.room.message#m.text
@@ -1,14 +1,10 @@
{
- "age": 242352,
+ "$ref": "core/room_event.json",
+ "type": "m.room.message",
"content": {
"body": "This is an example text message",
"msgtype": "m.text",
"format": "org.matrix.custom.html",
"formatted_body": "This is an example text message"
- },
- "origin_server_ts": 1431961217939,
- "event_id": "$WLGTSEFSEF:localhost",
- "type": "m.room.message",
- "room_id": "!Cuyf34gef24t:localhost",
- "sender": "@example:localhost"
+ }
}
diff --git a/event-schemas/examples/m.room.message#m.video b/event-schemas/examples/m.room.message#m.video
index 576d80de4..304fbfbd1 100644
--- a/event-schemas/examples/m.room.message#m.video
+++ b/event-schemas/examples/m.room.message#m.video
@@ -1,10 +1,11 @@
{
- "age": 146,
+ "$ref": "core/room_event.json",
+ "type": "m.room.message",
"content": {
"body": "Gangnam Style",
- "url": "mxc://localhost/a526eYUSFFxlgbQYZmo442",
+ "url": "mxc://domain.com/a526eYUSFFxlgbQYZmo442",
"info": {
- "thumbnail_url": "mxc://localhost/FHyPlCeYUSFFxlgbQYZmoEoe",
+ "thumbnail_url": "mxc://domain.com/FHyPlCeYUSFFxlgbQYZmoEoe",
"thumbnail_info": {
"mimetype": "image/jpeg",
"size": 46144,
@@ -18,10 +19,5 @@
"mimetype": "video/mp4"
},
"msgtype": "m.video"
- },
- "event_id": "$143273582443PhrSn:localhost",
- "origin_server_ts": 1432735824653,
- "room_id": "!jEsUZKDJdhlrceRyVU:localhost",
- "type": "m.room.message",
- "sender": "@example:localhost"
+ }
}
diff --git a/event-schemas/examples/m.room.message.feedback b/event-schemas/examples/m.room.message.feedback
index 16fe0ee09..e146e8743 100644
--- a/event-schemas/examples/m.room.message.feedback
+++ b/event-schemas/examples/m.room.message.feedback
@@ -1,12 +1,8 @@
{
- "age": 242352,
+ "$ref": "core/room_event.json",
+ "type": "m.room.message.feedback",
"content": {
"type": "delivered",
"target_event_id": "$WEIGFHFW:localhost"
- },
- "origin_server_ts": 1431961217939,
- "event_id": "$WLGTSEFSEF:localhost",
- "type": "m.room.message.feedback",
- "room_id": "!Cuyf34gef24t:localhost",
- "sender": "@example:localhost"
+ }
}
diff --git a/event-schemas/examples/m.room.name b/event-schemas/examples/m.room.name
index 87db2008e..e77e2b53a 100644
--- a/event-schemas/examples/m.room.name
+++ b/event-schemas/examples/m.room.name
@@ -1,12 +1,8 @@
{
- "age": 242352,
+ "$ref": "core/state_event.json",
+ "type": "m.room.name",
+ "state_key": "",
"content": {
"name": "The room name"
- },
- "state_key": "",
- "origin_server_ts": 1431961217939,
- "event_id": "$WLGTSEFSEF:localhost",
- "type": "m.room.name",
- "room_id": "!Cuyf34gef24t:localhost",
- "sender": "@example:localhost"
+ }
}
diff --git a/event-schemas/examples/m.room.pinned_events b/event-schemas/examples/m.room.pinned_events
index 6f41e97da..10d71a8d6 100644
--- a/event-schemas/examples/m.room.pinned_events
+++ b/event-schemas/examples/m.room.pinned_events
@@ -1,12 +1,8 @@
{
- "age": 242352,
- "content": {
- "pinned": ["$someevent:localhost"]
- },
- "state_key": "",
- "origin_server_ts": 1431961217939,
- "event_id": "$WLGTSEFSEF:localhost",
+ "$ref": "core/state_event.json",
"type": "m.room.pinned_events",
- "room_id": "!Cuyf34gef24t:localhost",
- "sender": "@example:localhost"
+ "state_key": "",
+ "content": {
+ "pinned": ["$someevent:domain.com"]
+ }
}
diff --git a/event-schemas/examples/m.room.power_levels b/event-schemas/examples/m.room.power_levels
index 2b0aaca55..ad741e88e 100644
--- a/event-schemas/examples/m.room.power_levels
+++ b/event-schemas/examples/m.room.power_levels
@@ -1,5 +1,7 @@
{
- "age": 242352,
+ "$ref": "core/state_event.json",
+ "type": "m.room.power_levels",
+ "state_key": "",
"content": {
"ban": 50,
"events": {
@@ -18,11 +20,5 @@
"notifications": {
"room": 20
}
- },
- "state_key": "",
- "origin_server_ts": 1431961217939,
- "event_id": "$WLGTSEFSEF:localhost",
- "type": "m.room.power_levels",
- "room_id": "!Cuyf34gef24t:localhost",
- "sender": "@example:localhost"
+ }
}
diff --git a/event-schemas/examples/m.room.redaction b/event-schemas/examples/m.room.redaction
index e24a8cdbe..42bc84115 100644
--- a/event-schemas/examples/m.room.redaction
+++ b/event-schemas/examples/m.room.redaction
@@ -1,14 +1,8 @@
{
- "unsigned": {
- "age": 242352
- },
- "content": {
- "reason": "Spamming"
- },
- "origin_server_ts": 1431961217939,
- "event_id": "$WLGTSEFSEF:localhost",
+ "$ref": "core/room_event.json",
"type": "m.room.redaction",
- "room_id": "!Cuyf34gef24t:localhost",
"redacts": "$fukweghifu23:localhost",
- "sender": "@example:localhost"
+ "content": {
+ "reason": "Spamming"
+ }
}
diff --git a/event-schemas/examples/m.room.third_party_invite b/event-schemas/examples/m.room.third_party_invite
index 3f9d48fef..03f35375e 100644
--- a/event-schemas/examples/m.room.third_party_invite
+++ b/event-schemas/examples/m.room.third_party_invite
@@ -1,5 +1,7 @@
{
- "age": 242352,
+ "$ref": "core/state_event.json",
+ "type": "m.room.third_party_invite",
+ "state_key": "pc98",
"content": {
"display_name": "Alice Margatroid",
"key_validity_url": "https://magic.forest/verifykey",
@@ -8,11 +10,5 @@
"public_key": "def456",
"key_validity_url": "https://magic.forest/verifykey"
}]
- },
- "state_key": "pc98",
- "origin_server_ts": 1431961217939,
- "event_id": "$WLGTSEFSEF:localhost",
- "type": "m.room.third_party_invite",
- "room_id": "!Cuyf34gef24t:localhost",
- "sender": "@example:localhost"
+ }
}
diff --git a/event-schemas/examples/m.room.topic b/event-schemas/examples/m.room.topic
index 65daa9872..69e5d4f1c 100644
--- a/event-schemas/examples/m.room.topic
+++ b/event-schemas/examples/m.room.topic
@@ -1,12 +1,8 @@
{
- "age": 242352,
+ "$ref": "core/state_event.json",
+ "type": "m.room.topic",
+ "state_key": "",
"content": {
"topic": "A room topic"
- },
- "state_key": "",
- "origin_server_ts": 1431961217939,
- "event_id": "$WLGTSEFSEF:localhost",
- "type": "m.room.topic",
- "room_id": "!Cuyf34gef24t:localhost",
- "sender": "@example:localhost"
+ }
}
diff --git a/event-schemas/examples/m.room_key b/event-schemas/examples/m.room_key
index 53f83e522..dba497b42 100644
--- a/event-schemas/examples/m.room_key
+++ b/event-schemas/examples/m.room_key
@@ -1,9 +1,10 @@
{
+ "$ref": "core/event.json",
+ "type": "m.room_key",
"content": {
"algorithm": "m.megolm.v1.aes-sha2",
"room_id": "!Cuyf34gef24t:localhost",
"session_id": "X3lUlvLELLYxeTx4yOVu6UDpasGEVO0Jbu+QFnm0cKQ",
"session_key": "AgAAAADxKHa9uFxcXzwYoNueL5Xqi69IkD4sni8LlfJL7qNBEY..."
- },
- "type": "m.room_key"
+ }
}
diff --git a/event-schemas/examples/m.sticker b/event-schemas/examples/m.sticker
index f00e5b238..971cdc905 100644
--- a/event-schemas/examples/m.sticker
+++ b/event-schemas/examples/m.sticker
@@ -1,5 +1,6 @@
{
- "age": 242352,
+ "$ref": "core/room_event.json",
+ "type": "m.sticker",
"content": {
"body": "Landing",
"info": {
@@ -16,10 +17,5 @@
"size": 73602
},
"url": "mxc://matrix.org/sHhqkFCvSkFwtmvtETOtKnLP"
- },
- "origin_server_ts": 1431961217939,
- "event_id": "$WLGTSEFSEF:localhost",
- "type": "m.sticker",
- "room_id": "!Cuyf34gef24t:localhost",
- "sender": "@example:localhost"
+ }
}
diff --git a/event-schemas/examples/m.tag b/event-schemas/examples/m.tag
index 53dbc921a..0d61d91b6 100644
--- a/event-schemas/examples/m.tag
+++ b/event-schemas/examples/m.tag
@@ -1,4 +1,5 @@
{
+ "$ref": "core/event.json",
"type": "m.tag",
"content": {
"tags": {
diff --git a/event-schemas/examples/m.typing b/event-schemas/examples/m.typing
index 1d2c517b9..416b99688 100644
--- a/event-schemas/examples/m.typing
+++ b/event-schemas/examples/m.typing
@@ -1,7 +1,7 @@
{
- "type": "m.typing",
- "room_id": "!z0mnsuiwhifuhwwfw:matrix.org",
- "content": {
- "user_ids": ["@alice:matrix.org", "@bob:example.com"]
- }
+ "$ref": "core/room_edu.json",
+ "type": "m.typing",
+ "content": {
+ "user_ids": ["@alice:matrix.org", "@bob:example.com"]
+ }
}
diff --git a/scripts/templating/matrix_templates/units.py b/scripts/templating/matrix_templates/units.py
index 427b3a00f..a1bef7954 100644
--- a/scripts/templating/matrix_templates/units.py
+++ b/scripts/templating/matrix_templates/units.py
@@ -794,7 +794,7 @@ class MatrixUnits(Units):
logger.info("Reading event example: %s" % filepath)
try:
with open(filepath, "r", encoding="utf-8") as f:
- example = json.load(f)
+ example = resolve_references(filepath, json.load(f))
examples[filename] = examples.get(filename, [])
examples[filename].append(example)
if filename != event_name: