@@ -68,118 +68,118 @@ request being made was invalid.
6868
6969The common error codes are:
7070
71- ` M_FORBIDDEN `
71+ ` M_FORBIDDEN `
7272Forbidden access, e.g. joining a room without permission, failed login.
7373
74- ` M_UNKNOWN_TOKEN `
74+ ` M_UNKNOWN_TOKEN `
7575The access token specified was not recognised.
7676
7777An additional response parameter, ` soft_logout ` , might be present on the
7878response for 401 HTTP status codes. See [ the soft logout
7979section] ( #soft-logout ) for more information.
8080
81- ` M_MISSING_TOKEN `
81+ ` M_MISSING_TOKEN `
8282No access token was specified for the request.
8383
84- ` M_BAD_JSON `
84+ ` M_BAD_JSON `
8585Request contained valid JSON, but it was malformed in some way, e.g.
8686missing required keys, invalid values for keys.
8787
88- ` M_NOT_JSON `
88+ ` M_NOT_JSON `
8989Request did not contain valid JSON.
9090
91- ` M_NOT_FOUND `
91+ ` M_NOT_FOUND `
9292No resource was found for this request.
9393
94- ` M_LIMIT_EXCEEDED `
94+ ` M_LIMIT_EXCEEDED `
9595Too many requests have been sent in a short period of time. Wait a while
9696then try again.
9797
98- ` M_UNKNOWN `
98+ ` M_UNKNOWN `
9999An unknown error has occurred.
100100
101101Other error codes the client might encounter are:
102102
103- ` M_UNRECOGNIZED `
103+ ` M_UNRECOGNIZED `
104104The server did not understand the request.
105105
106- ` M_UNAUTHORIZED `
106+ ` M_UNAUTHORIZED `
107107The request was not correctly authorized. Usually due to login failures.
108108
109- ` M_USER_DEACTIVATED `
109+ ` M_USER_DEACTIVATED `
110110The user ID associated with the request has been deactivated. Typically
111111for endpoints that prove authentication, such as ` /login ` .
112112
113- ` M_USER_IN_USE `
113+ ` M_USER_IN_USE `
114114Encountered when trying to register a user ID which has been taken.
115115
116- ` M_INVALID_USERNAME `
116+ ` M_INVALID_USERNAME `
117117Encountered when trying to register a user ID which is not valid.
118118
119- ` M_ROOM_IN_USE `
119+ ` M_ROOM_IN_USE `
120120Sent when the room alias given to the ` createRoom ` API is already in
121121use.
122122
123- ` M_INVALID_ROOM_STATE `
123+ ` M_INVALID_ROOM_STATE `
124124Sent when the initial state given to the ` createRoom ` API is invalid.
125125
126- ` M_THREEPID_IN_USE `
126+ ` M_THREEPID_IN_USE `
127127Sent when a threepid given to an API cannot be used because the same
128128threepid is already in use.
129129
130- ` M_THREEPID_NOT_FOUND `
130+ ` M_THREEPID_NOT_FOUND `
131131Sent when a threepid given to an API cannot be used because no record
132132matching the threepid was found.
133133
134- ` M_THREEPID_AUTH_FAILED `
134+ ` M_THREEPID_AUTH_FAILED `
135135Authentication could not be performed on the third party identifier.
136136
137- ` M_THREEPID_DENIED `
137+ ` M_THREEPID_DENIED `
138138The server does not permit this third party identifier. This may happen
139139if the server only permits, for example, email addresses from a
140140particular domain.
141141
142- ` M_SERVER_NOT_TRUSTED `
142+ ` M_SERVER_NOT_TRUSTED `
143143The client's request used a third party server, e.g. identity server,
144144that this server does not trust.
145145
146- ` M_UNSUPPORTED_ROOM_VERSION `
146+ ` M_UNSUPPORTED_ROOM_VERSION `
147147The client's request to create a room used a room version that the
148148server does not support.
149149
150- ` M_INCOMPATIBLE_ROOM_VERSION `
150+ ` M_INCOMPATIBLE_ROOM_VERSION `
151151The client attempted to join a room that has a version the server does
152152not support. Inspect the ` room_version ` property of the error response
153153for the room's version.
154154
155- ` M_BAD_STATE `
155+ ` M_BAD_STATE `
156156The state change requested cannot be performed, such as attempting to
157157unban a user who is not banned.
158158
159- ` M_GUEST_ACCESS_FORBIDDEN `
159+ ` M_GUEST_ACCESS_FORBIDDEN `
160160The room or resource does not permit guests to access it.
161161
162- ` M_CAPTCHA_NEEDED `
162+ ` M_CAPTCHA_NEEDED `
163163A Captcha is required to complete the request.
164164
165- ` M_CAPTCHA_INVALID `
165+ ` M_CAPTCHA_INVALID `
166166The Captcha provided did not match what was expected.
167167
168- ` M_MISSING_PARAM `
168+ ` M_MISSING_PARAM `
169169A required parameter was missing from the request.
170170
171- ` M_INVALID_PARAM `
171+ ` M_INVALID_PARAM `
172172A parameter that was specified has the wrong value. For example, the
173173server expected an integer and instead received a string.
174174
175- ` M_TOO_LARGE `
175+ ` M_TOO_LARGE `
176176The request or entity was too large.
177177
178- ` M_EXCLUSIVE `
178+ ` M_EXCLUSIVE `
179179The resource being requested is reserved by an application service, or
180180the application service making the request has not created the resource.
181181
182- ` M_RESOURCE_LIMIT_EXCEEDED `
182+ ` M_RESOURCE_LIMIT_EXCEEDED `
183183The request cannot be completed because the homeserver has reached a
184184resource limit imposed on it. For example, a homeserver held in a shared
185185hosting 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
189189state (e.g.: sending messages, account data, etc) and not routes which
190190only read state (e.g.: ` /sync ` , get account data, etc).
191191
192- ` M_CANNOT_LEAVE_SERVER_NOTICE_ROOM `
192+ ` M_CANNOT_LEAVE_SERVER_NOTICE_ROOM `
193193The user is unable to reject an invite to join the server notices room.
194194See the [ Server Notices] ( #server-notices ) module for more information.
195195
@@ -238,23 +238,23 @@ time.
238238
239239In this section, the following terms are used with specific meanings:
240240
241- ` PROMPT `
241+ ` PROMPT `
242242Retrieve the specific piece of information from the user in a way which
243243fits within the existing client user experience, if the client is
244244inclined to do so. Failure can take place instead if no good user
245245experience for this is possible at this point.
246246
247- ` IGNORE `
247+ ` IGNORE `
248248Stop the current auto-discovery mechanism. If no more auto-discovery
249249mechanisms are available, then the client may use other methods of
250250determining the required parameters, such as prompting the user, or
251251using default values.
252252
253- ` FAIL_PROMPT `
253+ ` FAIL_PROMPT `
254254Inform the user that auto-discovery failed due to invalid/empty data and
255255` PROMPT ` for the parameter.
256256
257- ` FAIL_ERROR `
257+ ` FAIL_ERROR `
258258Inform the user that auto-discovery did not return any usable URLs. Do
259259not continue further with the current login process. At this point,
260260valid 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
893893fields giving the information required to identify the user as described
894894below.
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
17121712creator. It will also generate several other events in order to manage
17131713permissions 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
17781778relation 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:
17861788There is an exception to the requirement that a user join a room before
17871789sending events to it: users may send an ` m.room.member ` event to a room
17881790with ` 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
17911794Some rooms require that users be invited to it before they can join;
17921795others allow anyone to join. Whether a given room is an "invite-only"
17931796room is determined by the room config key ` m.room.join_rules ` . It can
17941797have one of the following values:
17951798
1796- ` public `
1799+ ` public `
17971800This room is free for anyone to join without an invite.
17981801
1799- ` invite `
1802+ ` invite `
18001803This 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+
18021810The 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
18431859A user can leave a room to stop receiving events for that room. A user
18441860must have been invited to or have joined the room before they are
18451861eligible 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
18501868Whether 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
18521870re-join the room.
18531871
18541872A user can also forget a room which they have left. Rooms which have
18551873been 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
18581876A user may wish to force another user to leave a room. This can be done
18591877by 'kicking' the other user. To do so, the user performing the kick MUST
0 commit comments