Skip to content

Commit c090e35

Browse files
turt2liverichvdh
authored andcommitted
Add knocking to the spec
Spec for #2998 Spec for #2403 This deliberately does not help towards fixing #3153 in order to remain consistent with prior room versions, and to keep the diff smaller on this change. A future change will address room version legibility.
1 parent 83a60f8 commit c090e35

17 files changed

+779
-103
lines changed

content/_index.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -327,12 +327,12 @@ sent to the room `!qporfwt:matrix.org`:
327327
Federation maintains *shared data structures* per-room between multiple
328328
homeservers. The data is split into `message events` and `state events`.
329329

330-
Message events:
330+
Message events:
331331
These describe transient 'once-off' activity in a room such as an
332332
instant messages, VoIP call setups, file transfers, etc. They generally
333333
describe communication activity.
334334

335-
State events:
335+
State events:
336336
These describe updates to a given piece of persistent information
337337
('state') related to a room, such as the room's name, topic, membership,
338338
participating servers, etc. State is modelled as a lookup table of
@@ -505,7 +505,7 @@ stable and unstable periodically for a variety of reasons, including
505505
discovered security vulnerabilities and age.
506506

507507
Clients should not ask room administrators to upgrade their rooms if the
508-
room is running a stable version. Servers SHOULD use room version 6 as
508+
room is running a stable version. Servers SHOULD use **room version 6** as
509509
the default room version when creating new rooms.
510510

511511
The available room versions are:
@@ -522,10 +522,11 @@ The available room versions are:
522522
signing key validity periods.
523523
- [Version 6](/rooms/v6) - **Stable**. Alters several
524524
authorization rules for events.
525+
- [Version 7](/rooms/v7) - **Stable**. Introduces knocking.
525526

526527
## Specification Versions
527528

528-
The specification for each API is versioned in the form `rX.Y.Z`.
529+
The specification for each API is versioned in the form `rX.Y.Z`.
529530
- A change to `X` reflects a breaking change: a client implemented
530531
against `r1.0.0` may need changes to work with a server which
531532
supports (only) `r2.0.0`.

content/client-server-api/_index.md

+92-74
Original file line numberDiff line numberDiff line change
@@ -68,118 +68,118 @@ request being made was invalid.
6868

6969
The common error codes are:
7070

71-
`M_FORBIDDEN`
71+
`M_FORBIDDEN`
7272
Forbidden access, e.g. joining a room without permission, failed login.
7373

74-
`M_UNKNOWN_TOKEN`
74+
`M_UNKNOWN_TOKEN`
7575
The access token specified was not recognised.
7676

7777
An additional response parameter, `soft_logout`, might be present on the
7878
response for 401 HTTP status codes. See [the soft logout
7979
section](#soft-logout) for more information.
8080

81-
`M_MISSING_TOKEN`
81+
`M_MISSING_TOKEN`
8282
No access token was specified for the request.
8383

84-
`M_BAD_JSON`
84+
`M_BAD_JSON`
8585
Request contained valid JSON, but it was malformed in some way, e.g.
8686
missing required keys, invalid values for keys.
8787

88-
`M_NOT_JSON`
88+
`M_NOT_JSON`
8989
Request did not contain valid JSON.
9090

91-
`M_NOT_FOUND`
91+
`M_NOT_FOUND`
9292
No resource was found for this request.
9393

94-
`M_LIMIT_EXCEEDED`
94+
`M_LIMIT_EXCEEDED`
9595
Too many requests have been sent in a short period of time. Wait a while
9696
then try again.
9797

98-
`M_UNKNOWN`
98+
`M_UNKNOWN`
9999
An unknown error has occurred.
100100

101101
Other error codes the client might encounter are:
102102

103-
`M_UNRECOGNIZED`
103+
`M_UNRECOGNIZED`
104104
The server did not understand the request.
105105

106-
`M_UNAUTHORIZED`
106+
`M_UNAUTHORIZED`
107107
The request was not correctly authorized. Usually due to login failures.
108108

109-
`M_USER_DEACTIVATED`
109+
`M_USER_DEACTIVATED`
110110
The user ID associated with the request has been deactivated. Typically
111111
for endpoints that prove authentication, such as `/login`.
112112

113-
`M_USER_IN_USE`
113+
`M_USER_IN_USE`
114114
Encountered when trying to register a user ID which has been taken.
115115

116-
`M_INVALID_USERNAME`
116+
`M_INVALID_USERNAME`
117117
Encountered when trying to register a user ID which is not valid.
118118

119-
`M_ROOM_IN_USE`
119+
`M_ROOM_IN_USE`
120120
Sent when the room alias given to the `createRoom` API is already in
121121
use.
122122

123-
`M_INVALID_ROOM_STATE`
123+
`M_INVALID_ROOM_STATE`
124124
Sent when the initial state given to the `createRoom` API is invalid.
125125

126-
`M_THREEPID_IN_USE`
126+
`M_THREEPID_IN_USE`
127127
Sent when a threepid given to an API cannot be used because the same
128128
threepid is already in use.
129129

130-
`M_THREEPID_NOT_FOUND`
130+
`M_THREEPID_NOT_FOUND`
131131
Sent when a threepid given to an API cannot be used because no record
132132
matching the threepid was found.
133133

134-
`M_THREEPID_AUTH_FAILED`
134+
`M_THREEPID_AUTH_FAILED`
135135
Authentication could not be performed on the third party identifier.
136136

137-
`M_THREEPID_DENIED`
137+
`M_THREEPID_DENIED`
138138
The server does not permit this third party identifier. This may happen
139139
if the server only permits, for example, email addresses from a
140140
particular domain.
141141

142-
`M_SERVER_NOT_TRUSTED`
142+
`M_SERVER_NOT_TRUSTED`
143143
The client's request used a third party server, e.g. identity server,
144144
that this server does not trust.
145145

146-
`M_UNSUPPORTED_ROOM_VERSION`
146+
`M_UNSUPPORTED_ROOM_VERSION`
147147
The client's request to create a room used a room version that the
148148
server does not support.
149149

150-
`M_INCOMPATIBLE_ROOM_VERSION`
150+
`M_INCOMPATIBLE_ROOM_VERSION`
151151
The client attempted to join a room that has a version the server does
152152
not support. Inspect the `room_version` property of the error response
153153
for the room's version.
154154

155-
`M_BAD_STATE`
155+
`M_BAD_STATE`
156156
The state change requested cannot be performed, such as attempting to
157157
unban a user who is not banned.
158158

159-
`M_GUEST_ACCESS_FORBIDDEN`
159+
`M_GUEST_ACCESS_FORBIDDEN`
160160
The room or resource does not permit guests to access it.
161161

162-
`M_CAPTCHA_NEEDED`
162+
`M_CAPTCHA_NEEDED`
163163
A Captcha is required to complete the request.
164164

165-
`M_CAPTCHA_INVALID`
165+
`M_CAPTCHA_INVALID`
166166
The Captcha provided did not match what was expected.
167167

168-
`M_MISSING_PARAM`
168+
`M_MISSING_PARAM`
169169
A required parameter was missing from the request.
170170

171-
`M_INVALID_PARAM`
171+
`M_INVALID_PARAM`
172172
A parameter that was specified has the wrong value. For example, the
173173
server expected an integer and instead received a string.
174174

175-
`M_TOO_LARGE`
175+
`M_TOO_LARGE`
176176
The request or entity was too large.
177177

178-
`M_EXCLUSIVE`
178+
`M_EXCLUSIVE`
179179
The resource being requested is reserved by an application service, or
180180
the application service making the request has not created the resource.
181181

182-
`M_RESOURCE_LIMIT_EXCEEDED`
182+
`M_RESOURCE_LIMIT_EXCEEDED`
183183
The request cannot be completed because the homeserver has reached a
184184
resource limit imposed on it. For example, a homeserver held in a shared
185185
hosting environment may reach a resource limit if it starts using too
@@ -189,7 +189,7 @@ Typically, this error will appear on routes which attempt to modify
189189
state (e.g.: sending messages, account data, etc) and not routes which
190190
only read state (e.g.: `/sync`, get account data, etc).
191191

192-
`M_CANNOT_LEAVE_SERVER_NOTICE_ROOM`
192+
`M_CANNOT_LEAVE_SERVER_NOTICE_ROOM`
193193
The user is unable to reject an invite to join the server notices room.
194194
See the [Server Notices](#server-notices) module for more information.
195195

@@ -238,23 +238,23 @@ time.
238238

239239
In this section, the following terms are used with specific meanings:
240240

241-
`PROMPT`
241+
`PROMPT`
242242
Retrieve the specific piece of information from the user in a way which
243243
fits within the existing client user experience, if the client is
244244
inclined to do so. Failure can take place instead if no good user
245245
experience for this is possible at this point.
246246

247-
`IGNORE`
247+
`IGNORE`
248248
Stop the current auto-discovery mechanism. If no more auto-discovery
249249
mechanisms are available, then the client may use other methods of
250250
determining the required parameters, such as prompting the user, or
251251
using default values.
252252

253-
`FAIL_PROMPT`
253+
`FAIL_PROMPT`
254254
Inform the user that auto-discovery failed due to invalid/empty data and
255255
`PROMPT` for the parameter.
256256

257-
`FAIL_ERROR`
257+
`FAIL_ERROR`
258258
Inform the user that auto-discovery did not return any usable URLs. Do
259259
not continue further with the current login process. At this point,
260260
valid data was obtained, but no server is available to serve the client.
@@ -606,7 +606,7 @@ flow with three stages will resemble the following diagram:
606606

607607
#### Authentication types
608608

609-
This specification defines the following auth types:
609+
This specification defines the following auth types:
610610
- `m.login.password`
611611
- `m.login.recaptcha`
612612
- `m.login.sso`
@@ -893,7 +893,7 @@ type of identifier being used, and depending on the type, has other
893893
fields giving the information required to identify the user as described
894894
below.
895895

896-
This specification defines the following identifier types:
896+
This specification defines the following identifier types:
897897
- `m.id.user`
898898
- `m.id.thirdparty`
899899
- `m.id.phone`
@@ -1712,7 +1712,7 @@ event also has a `creator` key which contains the user ID of the room
17121712
creator. It will also generate several other events in order to manage
17131713
permissions in this room. This includes:
17141714

1715-
- `m.room.power_levels` : Sets the power levels of users and required power
1715+
- `m.room.power_levels` : Sets the power levels of users and required power
17161716
levels for various actions within the room such as sending events.
17171717

17181718
- `m.room.join_rules` : Whether the room is "invite-only" or not.
@@ -1778,6 +1778,8 @@ in that room. There are several states in which a user may be, in
17781778
relation to a room:
17791779

17801780
- Unrelated (the user cannot send or receive events in the room)
1781+
- Knocking (the user has requested to participate in the room, but has
1782+
not yet been allowed to)
17811783
- Invited (the user has been invited to participate in the room, but
17821784
is not yet participating)
17831785
- Joined (the user can send and receive events in the room)
@@ -1786,49 +1788,28 @@ relation to a room:
17861788
There is an exception to the requirement that a user join a room before
17871789
sending events to it: users may send an `m.room.member` event to a room
17881790
with `content.membership` set to `leave` to reject an invitation if they
1789-
have currently been invited to a room but have not joined it.
1791+
have currently been invited to a room but have not joined it. The same
1792+
applies for retracting knocks on the room that the user sent.
17901793

17911794
Some rooms require that users be invited to it before they can join;
17921795
others allow anyone to join. Whether a given room is an "invite-only"
17931796
room is determined by the room config key `m.room.join_rules`. It can
17941797
have one of the following values:
17951798

1796-
`public`
1799+
`public`
17971800
This room is free for anyone to join without an invite.
17981801

1799-
`invite`
1802+
`invite`
18001803
This room can only be joined if you were invited.
18011804

1805+
`knock`
1806+
This room can only be joined if you were invited, and allows anyone to
1807+
request an invite to the room. Note that this join rule is only available
1808+
to rooms based upon [room version 7](/rooms/v7).
1809+
18021810
The allowable state transitions of membership are:
18031811

1804-
```
1805-
/ban
1806-
+------------------------------------------------------+
1807-
| |
1808-
| +----------------+ +----------------+ |
1809-
| | /leave | | | |
1810-
| | v v | |
1811-
/invite +--------+ +-------+ | |
1812-
------------>| invite |<----------| leave |----+ | |
1813-
+--------+ /invite +-------+ | | |
1814-
| | ^ | | |
1815-
| | | | | |
1816-
/join | +---------------+ | | | |
1817-
| | /join if | | | |
1818-
| | join_rules | | /ban | /unban |
1819-
| | public /leave | | | |
1820-
v v or | | | |
1821-
+------+ /kick | | | |
1822-
------------>| join |-------------------+ | | |
1823-
/join +------+ v | |
1824-
if | +-----+ | |
1825-
join_rules +-------------------------->| ban |-----+ |
1826-
public /ban +-----+ |
1827-
^ ^ |
1828-
| | |
1829-
----------------------------------------------+ +----------------------+
1830-
/ban
1831-
```
1812+
![membership-flow-diagram](/diagrams/membership.png)
18321813

18331814
{{% http-api spec="client-server" api="list_joined_rooms" %}}
18341815

@@ -1838,22 +1819,59 @@ The allowable state transitions of membership are:
18381819

18391820
{{% http-api spec="client-server" api="joining" %}}
18401821

1822+
##### Knocking on rooms
1823+
1824+
<!--
1825+
This section is here because it's most similar to being invited/joining a
1826+
room, though has added complexity which needs to be explained. Otherwise
1827+
this will have been just the API definition and nothing more (like invites).
1828+
-->
1829+
1830+
If the join rules allow, external users to the room can `/knock` on it to
1831+
request permission to join. Users with appropriate permissions within the
1832+
room can then approve (`/invite`) or deny (`/kick`, `/ban`, or otherwise
1833+
set membership to `leave`) the knock. Knocks can be retracted by calling
1834+
`/leave` or otherwise setting membership to `leave`.
1835+
1836+
Users who are currently in the room, already invited, or banned cannot
1837+
knock on the room.
1838+
1839+
To accept another user's knock, the user must have permission to invite
1840+
users to the room. To reject another user's knock, the user must have
1841+
permission to either kick or ban users (whichever is being performed).
1842+
Note that setting another user's membership to `leave` is kicking them.
1843+
1844+
The knocking homeserver should assume that an invite to the room means
1845+
that the knock was accepted, even if the invite is not explicitly related
1846+
to the knock.
1847+
1848+
Homeservers are permitted to automatically accept invites as a result of
1849+
knocks as they should be aware of the user's intent to join the room. If
1850+
the homeserver is not auto-accepting invites (or there was an unrecoverable
1851+
problem with accepting it), the invite is expected to be passed down normally
1852+
to the client to handle. Clients can expect to see the join event if the
1853+
server chose to auto-accept.
1854+
1855+
{{% http-api spec="client-server" api="knocking" %}}
1856+
18411857
#### Leaving rooms
18421858

18431859
A user can leave a room to stop receiving events for that room. A user
18441860
must have been invited to or have joined the room before they are
18451861
eligible to leave the room. Leaving a room to which the user has been
1846-
invited rejects the invite. Once a user leaves a room, it will no longer
1847-
appear in the response to the [`/sync`](/client-server-api/#get_matrixclientr0sync) API unless it is explicitly
1848-
requested via a filter with the `include_leave` field set to `true`.
1862+
invited rejects the invite, and can retract a knock. Once a user leaves
1863+
a room, it will no longer appear in the response to the
1864+
[`/sync`](/client-server-api/#get_matrixclientr0sync) API unless it is
1865+
explicitly requested via a filter with the `include_leave` field set
1866+
to `true`.
18491867

18501868
Whether or not they actually joined the room, if the room is an
18511869
"invite-only" room the user will need to be re-invited before they can
18521870
re-join the room.
18531871

18541872
A user can also forget a room which they have left. Rooms which have
18551873
been forgotten will never appear the response to the [`/sync`](/client-server-api/#get_matrixclientr0sync) API,
1856-
until the user re-joins or is re-invited.
1874+
until the user re-joins, is re-invited, or knocks.
18571875

18581876
A user may wish to force another user to leave a room. This can be done
18591877
by 'kicking' the other user. To do so, the user performing the kick MUST

content/rooms/_index.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ weight: 60
1010
* [Room Version 4](v4)
1111
* [Room Version 5](v5)
1212
* [Room Version 6](v6)
13+
* [Room Version 7](v7)

0 commit comments

Comments
 (0)