Skip to content

Commit f14e181

Browse files
turt2liveneilalexanderrichvdh
authored
Specify room version 10: knock_restricted and int power levels (#1099)
* Clarification on historical power level handling * Revert "Clarification on historical power level handling" This reverts commit f443b3d. * Clean up * Let us try this again not using VS Code * Markdown is full of mysteries * Move stringy power levels to room versions * Describe range * Fix minor issues with previous room version stuff * Copy/paste v9 into v10 * Describe deprecated formatting * Paste unmodified auth rules from v8 into v10 * Move 9.1 to 9.3, add 9.1 and 9.2 for integer enforcement * Add knock_restricted to v10 auth * Misc cleanup and clarification for fragments * Describe `knock_restricted` client changes * Changelogs * spelling * Apply suggestions from code review Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> * Apply code review suggestions manually * Fix v9 redactions * Fix auth rules clarity issues * Apply suggestions from code review Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> * Remove false integer requirements Co-authored-by: Neil Alexander <neilalexander@users.noreply.github.com> Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
1 parent e70045f commit f14e181

File tree

23 files changed

+494
-56
lines changed

23 files changed

+494
-56
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add support for a new `knock_restricted` join rule in supported room versions, as per [MSC3787](https://github.com/matrix-org/matrix-spec-proposals/pull/3787).
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Clarify that room versions 1 through 9 accept stringy power levels, as noted by [MSC3667](https://github.com/matrix-org/matrix-spec-proposals/pull/3667).
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add room version 10 as per [MSC3604](https://github.com/matrix-org/matrix-spec-proposals/pull/3604).
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Enforce integer power levels in room version 10 as per [MSC3667](https://github.com/matrix-org/matrix-spec-proposals/pull/3667).
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add a `knock_restricted` join rule supported by room version 10 as per [MSC3787](https://github.com/matrix-org/matrix-spec-proposals/pull/3787).
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Clarify the historical handling of non-integer power levels.

content/client-server-api/_index.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2026,6 +2026,13 @@ room listed in the join rules. If the server cannot verify membership for any
20262026
of the listed rooms then you can only join with an invite. Note that this rule
20272027
is only expected to work in room versions [which support it](/rooms/#feature-matrix).
20282028

2029+
{{% added-in v="1.3" %}} `knock_restricted`
2030+
This room can be joined as though it was `restricted` *or* `knock`. If you
2031+
interact with the room using knocking, the `knock` rule takes effect whereas
2032+
trying to join the room without an invite applies the `restricted` join rule.
2033+
Note that this rule is only expected to work in room versions
2034+
[which support it](/rooms/#feature-matrix).
2035+
20292036
The allowable state transitions of membership are:
20302037

20312038
![membership-flow-diagram](/diagrams/membership.png)
@@ -2041,6 +2048,15 @@ The allowable state transitions of membership are:
20412048
##### Knocking on rooms
20422049

20432050
{{% added-in v="1.1" %}}
2051+
{{% changed-in v="1.3" %}}
2052+
2053+
{{% boxes/note %}}
2054+
As of `v1.3`, it is possible to knock on a [restricted room](#restricted-rooms)
2055+
if the room supports and is using the `knock_restricted` join rule.
2056+
2057+
Note that `knock_restricted` is only expected to work in room versions
2058+
[which support it](/rooms/#feature-matrix).
2059+
{{% /boxes/note %}}
20442060

20452061
<!--
20462062
This section is here because it's most similar to being invited/joining a
@@ -2078,6 +2094,15 @@ server chose to auto-accept.
20782094
##### Restricted rooms
20792095

20802096
{{% added-in v="1.2" %}}
2097+
{{% changed-in v="1.3" %}}
2098+
2099+
{{% boxes/note %}}
2100+
As of `v1.3`, it is possible to [knock](#knocking-on-rooms) on a restricted
2101+
room if the room supports and is using the `knock_restricted` join rule.
2102+
2103+
Note that `knock_restricted` is only expected to work in room versions
2104+
[which support it](/rooms/#feature-matrix).
2105+
{{% /boxes/note %}}
20812106

20822107
Restricted rooms are rooms with a `join_rule` of `restricted`. These rooms
20832108
are accompanied by "allow conditions" as described in the

content/rooms/_index.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@ Alternatively, consider flipping the column/row organization to be features
3636
up top and versions on the left.
3737
-->
3838

39-
| Feature \ Version | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
40-
|-------------------|---|---|---|---|---|---|---|---|---|
41-
| **Knocking** ||||||||||
42-
| **Restricted join rules** ||||||||||
39+
| Feature \ Version | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
40+
|-------------------|---|---|---|---|---|---|---|---|---|----|
41+
| **Knocking** |||||||||||
42+
| **Restricted join rules** |||||||||||
43+
| **`knock_restricted` join rule** |||||||||||
4344

4445
## Complete list of room versions
4546

@@ -73,6 +74,8 @@ The available room versions are:
7374
of another room to join without invite.
7475
- [Version 9](/rooms/v9) - **Stable**. Builds on v8 to fix issues when
7576
redacting some membership events.
77+
- [Version 10](/rooms/v10) - **Stable**. Enforces integer-only power levels
78+
and adds `knock_restricted` join rule.
7679

7780
## Room version grammar
7881

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
toc_hide: true
3+
---
4+
5+
Events sent into rooms of this version can have formats which are different
6+
from their normal schema. Those cases are documented here.
7+
8+
{{% boxes/warning %}}
9+
The behaviour described here is preserved strictly for backwards compatibility
10+
only. A homeserver should take reasonable precautions to prevent users from
11+
sending these so-called "malformed" events, and must never rely on the behaviours
12+
described here as a default.
13+
{{% /boxes/warning %}}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
toc_hide: true
3+
---
4+
5+
##### `m.room.power_levels` events accept values as strings
6+
7+
In order to maintain backwards compatibility with early implementations,
8+
each of the integer-valued properties within
9+
[`m.room.power_levels`](/client-server-api#mroompower_levels) events can
10+
be encoded as strings instead of integers. This includes the nested values
11+
within the `events`, `notifications` and `users` properties.
12+
For example, the following is a valid `m.room.power_levels` event in this room version:
13+
14+
```json
15+
{
16+
"content": {
17+
"ban": "50",
18+
"events": {
19+
"m.room.power_levels": "100"
20+
},
21+
"events_default": "0",
22+
"state_default": "50",
23+
"users": {
24+
"@example:localhost": "100"
25+
},
26+
"users_default": "0"
27+
},
28+
"origin_server_ts": 1432735824653,
29+
"room_id": "!jEsUZKDJdhlrceRyVU:example.org",
30+
"sender": "@example:example.org",
31+
"state_key": "",
32+
"type": "m.room.power_levels"
33+
}
34+
```
35+
36+
When the value is representative of an integer, they must be the following format:
37+
38+
* a single base 10 integer, no float values or decimal points, optionally with
39+
any number of leading zeroes (`"100"`, `"000100"`);
40+
* optionally prefixed with a single `-` or `+` character before the integer (`"+100"`,
41+
`"-100"`).
42+
* optionally with any number of leading or trailing whitespace characters (`" 100 "`,
43+
`" 00100 "`, `" +100 "`, `" -100 "`);

0 commit comments

Comments
 (0)