Spec ?format=event|content on GET /state/:type[/:key] (original) (raw)
This has always been missing from the spec, but appears to have always been a feature of Synapse.
- Spec: https://spec.matrix.org/v1.2/client-server-api/#get_matrixclientv3roomsroomidstateeventtypestatekey
- Implementation: Allow clients to ask for the whole of a single state event synapse#1094
This is quite useful as a feature given how many things could do with knowing the event ID of state event, and how many MSCs currently try to work around the issue. Off the top of my head:
- File trees (to be able to
rel_type: m.referencefile metadata) - Location sharing for beacons, if the sender lost their local state
- Various conference bot actions which rely on room state
- ... and a lot more that escape me as of writing.
Currently if a client wants this information and is sticking to the spec then they must call /sync or similar to locate the state event of interest. This is in fact what some clients, like the conference bot, do.
Evidence using curl
$ curl -s -X GET -H "Authorization: Bearer ${token}" 'http://localhost:8338/_matrix/client/v3/rooms/!GiwgmfWtVmChIrRDMe:localhost/state/m.room.create?format=event' | python -m json.tool
{
"type": "m.room.create",
"room_id": "!GiwgmfWtVmChIrRDMe:localhost",
"sender": "@travis:localhost",
"content": {
"room_version": "org.matrix.msc3787",
"predecessor": {
"room_id": "!FFDoPrcpeoLvVNcbmo:localhost",
"event_id": "$RqUrDYxf9LIklWsLelCnyFd-Qq95LXB0gXlUfgUwPEw"
},
"creator": "@travis:localhost"
},
"state_key": "",
"origin_server_ts": 1651631163723,
"unsigned": {
"age_ts": 1651631163723
}
}
$ curl -s -X GET -H "Authorization: Bearer ${token}" 'http://localhost:8338/_matrix/client/v3/rooms/!GiwgmfWtVmChIrRDMe:localhost/state/m.room.create?format=content' | python -m json.tool
{
"room_version": "org.matrix.msc3787",
"predecessor": {
"room_id": "!FFDoPrcpeoLvVNcbmo:localhost",
"event_id": "$RqUrDYxf9LIklWsLelCnyFd-Qq95LXB0gXlUfgUwPEw"
},
"creator": "@travis:localhost"
}
$ curl -s -X GET -H "Authorization: Bearer ${token}" 'http://localhost:8338/_matrix/client/v3/rooms/!GiwgmfWtVmChIrRDMe:localhost/state/m.room.create' | python -m json.tool
{
"room_version": "org.matrix.msc3787",
"predecessor": {
"room_id": "!FFDoPrcpeoLvVNcbmo:localhost",
"event_id": "$RqUrDYxf9LIklWsLelCnyFd-Qq95LXB0gXlUfgUwPEw"
},
"creator": "@travis:localhost"
}