Skip to content

Commit 46b977c

Browse files
committed
Describe and hoist stripped state to a first-class citizen
Fixes #3413 MSC: #3173
1 parent 4734f40 commit 46b977c

File tree

7 files changed

+80
-36
lines changed

7 files changed

+80
-36
lines changed

content/client-server-api/_index.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,6 +1399,65 @@ following field:
13991399
|--------------|--------------|--------------------------------------------------------------------------------------------------------------|
14001400
| state_key | string | **Required.** 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. State keys starting with an `@` are reserved for referencing user IDs, such as room members. With the exception of a few events, state events set with a given user's ID as the state key MUST only be set by that user. |
14011401

1402+
### Stripped state
1403+
1404+
Stripped state events are simplified state events to help a potential
1405+
joiner identify the room. These state events may only have the `sender`,
1406+
`type`, `state_key` and `content` keys present.
1407+
1408+
These stripped state events typically appear on invites, knocks, and in
1409+
other places where a user *could* join the room under the conditions
1410+
available (such as a [`restricted` room](#restricted-rooms)).
1411+
1412+
Clients should only use stripped state events so long as they don't have
1413+
access to the proper state of the room. Once the state of the room is
1414+
available, all stripped state should be discarded. In cases where the
1415+
client has an archived state of the room (such as after being kicked)
1416+
and the client is receiving stripped state for the room, such as from an
1417+
invite or knock, then the stripped state should take precedence until
1418+
fresh state can be acquired from a join.
1419+
1420+
The following state events should be represented as stripped state when
1421+
possible:
1422+
1423+
* [`m.room.create`](#mroomcreate)
1424+
* [`m.room.name`](#mroomname)
1425+
* [`m.room.avatar`](#mroomavatar)
1426+
* [`m.room.topic`](#mroomtopic)
1427+
* [`m.room.join_rules`](#mroomjoin_rules)
1428+
* [`m.room.canonical_alias`](#mroomcanonical_alias)
1429+
* [`m.room.encryption`](#mroomencryption)
1430+
1431+
{{% boxes/rationale %}}
1432+
These state events represent basic aesthetic information about the room
1433+
and give clients information about how to join the room, and what to
1434+
expect once joined.
1435+
1436+
The name, avatar, topic, and aliases are presented as aesthetic information
1437+
about the room, allowing users to make decisions about whether or not they
1438+
want to join the room.
1439+
1440+
The join rules are given to help the client determine *why* it is able to
1441+
potentially join. For example, annotating the room decoration with iconography
1442+
consistent with the respective join rule for the room.
1443+
1444+
The create event can help identify what kind of room is being joined, as it
1445+
may be a Space or other kind of room. The client might choose to render the
1446+
invite in a different area of the application as a result.
1447+
1448+
Similar to join rules, the encryption information is given to help clients
1449+
decorate the room with appropriate iconography or messaging.
1450+
{{% /boxes/rationale %}}
1451+
1452+
{{% boxes/warning %}}
1453+
Although stripped state is usually generated and provided by the server, it
1454+
is still possible to be incorrect on the receiving end. The stripped state
1455+
events are not signed and could theoretically be modified, or outdated due to
1456+
updates not being sent.
1457+
{{% /boxes/warning %}}
1458+
1459+
{{% event-fields event_type="stripped_state" %}}
1460+
14021461
### Size limits
14031462

14041463
The complete event MUST NOT be larger than 65536 bytes, when formatted

data/api/client-server/sync.yaml

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -264,23 +264,13 @@ paths:
264264
title: InviteState
265265
type: object
266266
description: |-
267-
The state of a room that the user has been invited
268-
to. These state events may only have the `sender`,
269-
`type`, `state_key` and `content` keys
270-
present. These events do not replace any state that
271-
the client already has for the room, for example if
272-
the client has archived the room. Instead the
273-
client should keep two separate copies of the
274-
state: the one from the `invite_state` and one
275-
from the archived `state`. If the client joins
276-
the room then the current state will be given as a
277-
delta against the archived `state` not the
278-
`invite_state`.
267+
The [stripped state](#stripped-state) of a room that the user has been invited
268+
to.
279269
properties:
280270
events:
281-
description: The StrippedState events that form the invite state.
271+
description: The [stripped state events](#stripped-state) that form the invite state.
282272
items:
283-
$ref: "../../event-schemas/schema/stripped_state.yaml"
273+
$ref: "../../event-schemas/schema/core-event-schema/stripped_state.yaml"
284274
type: array
285275
knock:
286276
title: Knocked rooms
@@ -295,14 +285,12 @@ paths:
295285
title: KnockState
296286
type: object
297287
description: |-
298-
The state of a room that the user has knocked upon. The state
299-
events contained here have the same restrictions as `InviteState`
300-
above.
288+
The [stripped state](#stripped-state) of a room that the user has knocked upon.
301289
properties:
302290
events:
303-
description: The StrippedState events that form the knock state.
291+
description: The [stripped state events](#stripped-state) that form the knock state.
304292
items:
305-
$ref: "../../event-schemas/schema/stripped_state.yaml"
293+
$ref: "../../event-schemas/schema/core-event-schema/stripped_state.yaml"
306294
type: array
307295
leave:
308296
title: Left rooms

data/api/server-server/invites-v1.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,10 @@ paths:
7878
invite_room_state:
7979
type: array
8080
description: |-
81-
An optional list of simplified events to help the receiver of the invite
82-
identify the room. The recommended events to include are the join rules,
83-
canonical alias, avatar, and name of the room.
81+
An optional list of [stripped state events](/client-server-api/#stripped-state)
82+
to help the receiver of the invite identify the room.
8483
items:
85-
$ref: "../../event-schemas/schema/stripped_state.yaml"
84+
$ref: "../../event-schemas/schema/core-event-schema/stripped_state.yaml"
8685
example:
8786
$ref: "../../event-schemas/examples/invite_room_state.json"
8887
example: {

data/api/server-server/invites-v2.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,10 @@ paths:
7979
invite_room_state:
8080
type: array
8181
description: |-
82-
An optional list of simplified events to help the receiver of the invite
83-
identify the room. The recommended events to include are the join rules,
84-
canonical alias, avatar, and name of the room.
82+
An optional list of [stripped state events](/client-server-api/#stripped-state)
83+
to help the receiver of the invite identify the room.
8584
items:
86-
$ref: "../../event-schemas/schema/stripped_state.yaml"
85+
$ref: "../../event-schemas/schema/core-event-schema/stripped_state.yaml"
8786
example:
8887
$ref: "../../event-schemas/examples/invite_room_state.json"
8988
required: ['room_version', 'event']

data/api/server-server/knocks.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,10 @@ paths:
285285
knock_room_state:
286286
type: array
287287
items:
288-
$ref: "../../event-schemas/schema/stripped_state.yaml"
288+
$ref: "../../event-schemas/schema/core-event-schema/stripped_state.yaml"
289289
description: |-
290-
A list of simplified events to help the initiator of the knock identify
291-
the room. The recommended events to include are the join rules, canonical
292-
alias, avatar, name, and encryption state of the room.
290+
An optional list of [stripped state events](/client-server-api/#stripped-state)
291+
to help the initiator of the knock identify the room.
293292
example:
294293
$ref: "../../event-schemas/examples/knock_room_state.json"
295294
required: ['knock_room_state']

data/event-schemas/schema/stripped_state.yaml renamed to data/event-schemas/schema/core-event-schema/stripped_state.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# difficult because the schema would be at two different locations, with
1919
# different relative pathing.
2020

21-
title: StrippedState
21+
title: StrippedStateEvent
2222
type: object
2323
description: |-
2424
A stripped down state event, with only the `type`, `state_key`,

data/event-schemas/schema/m.room.member.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ description: |-
1919
The `third_party_invite` property will be set if this invite is an `invite` event and is the successor of an `m.room.third_party_invite` event, and absent otherwise.
2020
2121
This event may also include an `invite_room_state` key inside the event's `unsigned` data.
22-
If present, this contains an array of `StrippedState` Events. These events provide information
23-
on a subset of state events such as the room name.
22+
If present, this contains an array of [stripped state events](/client-server-api/#stripped-state)
23+
to assist the receiver in identifying the room.
2424
2525
The user for which a membership applies is represented by the `state_key`. Under some conditions,
2626
the `sender` and `state_key` may not match - this may be interpreted as the `sender` affecting
@@ -136,7 +136,7 @@ properties:
136136
state for `m.room.avatar`, `m.room.canonical_alias`, `m.room.join_rules`, and `m.room.name`
137137
SHOULD be included.
138138
items:
139-
$ref: "stripped_state.yaml"
139+
$ref: "core-event-schema/stripped_state.yaml"
140140
type: array
141141
knock_room_state:
142142
description: |-
@@ -145,7 +145,7 @@ properties:
145145
the state for `m.room.avatar`, `m.room.canonical_alias`, `m.room.join_rules`, `m.room.name`,
146146
and `m.room.encryption` SHOULD be included.
147147
items:
148-
$ref: "stripped_state.yaml"
148+
$ref: "core-event-schema/stripped_state.yaml"
149149
type: array
150150
title: The current membership state of a user in the room.
151151
type: object

0 commit comments

Comments
 (0)