Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit d993c3b

Browse files
authoredNov 17, 2021
Add support for /_matrix/media/v3 APIs (#11371)
* Add support for `/_matrix/media/v3` APIs Signed-off-by: Aaron Raimist <[email protected]> * Update `workers.md` to use v3 client and media APIs Signed-off-by: Aaron Raimist <[email protected]> * Add changelog Signed-off-by: Aaron Raimist <[email protected]>
1 parent b76337f commit d993c3b

File tree

6 files changed

+60
-51
lines changed

6 files changed

+60
-51
lines changed
 

‎changelog.d/11371.feature

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add support for the `/_matrix/media/v3` APIs from Matrix v1.1.

‎docker/configure_workers_and_start.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"app": "synapse.app.user_dir",
4949
"listener_resources": ["client"],
5050
"endpoint_patterns": [
51-
"^/_matrix/client/(api/v1|r0|unstable)/user_directory/search$"
51+
"^/_matrix/client/(api/v1|r0|v3|unstable)/user_directory/search$"
5252
],
5353
"shared_extra_conf": {"update_user_directory": False},
5454
"worker_extra_conf": "",
@@ -85,10 +85,10 @@
8585
"app": "synapse.app.generic_worker",
8686
"listener_resources": ["client"],
8787
"endpoint_patterns": [
88-
"^/_matrix/client/(v2_alpha|r0)/sync$",
89-
"^/_matrix/client/(api/v1|v2_alpha|r0)/events$",
90-
"^/_matrix/client/(api/v1|r0)/initialSync$",
91-
"^/_matrix/client/(api/v1|r0)/rooms/[^/]+/initialSync$",
88+
"^/_matrix/client/(v2_alpha|r0|v3)/sync$",
89+
"^/_matrix/client/(api/v1|v2_alpha|r0|v3)/events$",
90+
"^/_matrix/client/(api/v1|r0|v3)/initialSync$",
91+
"^/_matrix/client/(api/v1|r0|v3)/rooms/[^/]+/initialSync$",
9292
],
9393
"shared_extra_conf": {},
9494
"worker_extra_conf": "",
@@ -146,19 +146,19 @@
146146
"app": "synapse.app.generic_worker",
147147
"listener_resources": ["client"],
148148
"endpoint_patterns": [
149-
"^/_matrix/client/(api/v1|r0|unstable)/rooms/.*/redact",
150-
"^/_matrix/client/(api/v1|r0|unstable)/rooms/.*/send",
151-
"^/_matrix/client/(api/v1|r0|unstable)/rooms/.*/(join|invite|leave|ban|unban|kick)$",
152-
"^/_matrix/client/(api/v1|r0|unstable)/join/",
153-
"^/_matrix/client/(api/v1|r0|unstable)/profile/",
149+
"^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/redact",
150+
"^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/send",
151+
"^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/(join|invite|leave|ban|unban|kick)$",
152+
"^/_matrix/client/(api/v1|r0|v3|unstable)/join/",
153+
"^/_matrix/client/(api/v1|r0|v3|unstable)/profile/",
154154
],
155155
"shared_extra_conf": {},
156156
"worker_extra_conf": "",
157157
},
158158
"frontend_proxy": {
159159
"app": "synapse.app.frontend_proxy",
160160
"listener_resources": ["client", "replication"],
161-
"endpoint_patterns": ["^/_matrix/client/(api/v1|r0|unstable)/keys/upload"],
161+
"endpoint_patterns": ["^/_matrix/client/(api/v1|r0|v3|unstable)/keys/upload"],
162162
"shared_extra_conf": {},
163163
"worker_extra_conf": (
164164
"worker_main_http_uri: http://127.0.0.1:%d"

‎docs/workers.md

+35-35
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,10 @@ This worker can handle API requests matching the following regular
182182
expressions:
183183

184184
# Sync requests
185-
^/_matrix/client/(v2_alpha|r0)/sync$
186-
^/_matrix/client/(api/v1|v2_alpha|r0)/events$
187-
^/_matrix/client/(api/v1|r0)/initialSync$
188-
^/_matrix/client/(api/v1|r0)/rooms/[^/]+/initialSync$
185+
^/_matrix/client/(v2_alpha|r0|v3)/sync$
186+
^/_matrix/client/(api/v1|v2_alpha|r0|v3)/events$
187+
^/_matrix/client/(api/v1|r0|v3)/initialSync$
188+
^/_matrix/client/(api/v1|r0|v3)/rooms/[^/]+/initialSync$
189189

190190
# Federation requests
191191
^/_matrix/federation/v1/event/
@@ -216,40 +216,40 @@ expressions:
216216
^/_matrix/federation/v1/send/
217217

218218
# Client API requests
219-
^/_matrix/client/(api/v1|r0|unstable)/createRoom$
220-
^/_matrix/client/(api/v1|r0|unstable)/publicRooms$
221-
^/_matrix/client/(api/v1|r0|unstable)/rooms/.*/joined_members$
222-
^/_matrix/client/(api/v1|r0|unstable)/rooms/.*/context/.*$
223-
^/_matrix/client/(api/v1|r0|unstable)/rooms/.*/members$
224-
^/_matrix/client/(api/v1|r0|unstable)/rooms/.*/state$
219+
^/_matrix/client/(api/v1|r0|v3|unstable)/createRoom$
220+
^/_matrix/client/(api/v1|r0|v3|unstable)/publicRooms$
221+
^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/joined_members$
222+
^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/context/.*$
223+
^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/members$
224+
^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/state$
225225
^/_matrix/client/unstable/org.matrix.msc2946/rooms/.*/spaces$
226226
^/_matrix/client/unstable/org.matrix.msc2946/rooms/.*/hierarchy$
227227
^/_matrix/client/unstable/im.nheko.summary/rooms/.*/summary$
228-
^/_matrix/client/(api/v1|r0|unstable)/account/3pid$
229-
^/_matrix/client/(api/v1|r0|unstable)/devices$
230-
^/_matrix/client/(api/v1|r0|unstable)/keys/query$
231-
^/_matrix/client/(api/v1|r0|unstable)/keys/changes$
228+
^/_matrix/client/(api/v1|r0|v3|unstable)/account/3pid$
229+
^/_matrix/client/(api/v1|r0|v3|unstable)/devices$
230+
^/_matrix/client/(api/v1|r0|v3|unstable)/keys/query$
231+
^/_matrix/client/(api/v1|r0|v3|unstable)/keys/changes$
232232
^/_matrix/client/versions$
233-
^/_matrix/client/(api/v1|r0|unstable)/voip/turnServer$
234-
^/_matrix/client/(api/v1|r0|unstable)/joined_groups$
235-
^/_matrix/client/(api/v1|r0|unstable)/publicised_groups$
236-
^/_matrix/client/(api/v1|r0|unstable)/publicised_groups/
237-
^/_matrix/client/(api/v1|r0|unstable)/rooms/.*/event/
238-
^/_matrix/client/(api/v1|r0|unstable)/joined_rooms$
239-
^/_matrix/client/(api/v1|r0|unstable)/search$
233+
^/_matrix/client/(api/v1|r0|v3|unstable)/voip/turnServer$
234+
^/_matrix/client/(api/v1|r0|v3|unstable)/joined_groups$
235+
^/_matrix/client/(api/v1|r0|v3|unstable)/publicised_groups$
236+
^/_matrix/client/(api/v1|r0|v3|unstable)/publicised_groups/
237+
^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/event/
238+
^/_matrix/client/(api/v1|r0|v3|unstable)/joined_rooms$
239+
^/_matrix/client/(api/v1|r0|v3|unstable)/search$
240240

241241
# Registration/login requests
242-
^/_matrix/client/(api/v1|r0|unstable)/login$
243-
^/_matrix/client/(r0|unstable)/register$
242+
^/_matrix/client/(api/v1|r0|v3|unstable)/login$
243+
^/_matrix/client/(r0|v3|unstable)/register$
244244
^/_matrix/client/unstable/org.matrix.msc3231/register/org.matrix.msc3231.login.registration_token/validity$
245245

246246
# Event sending requests
247-
^/_matrix/client/(api/v1|r0|unstable)/rooms/.*/redact
248-
^/_matrix/client/(api/v1|r0|unstable)/rooms/.*/send
249-
^/_matrix/client/(api/v1|r0|unstable)/rooms/.*/state/
250-
^/_matrix/client/(api/v1|r0|unstable)/rooms/.*/(join|invite|leave|ban|unban|kick)$
251-
^/_matrix/client/(api/v1|r0|unstable)/join/
252-
^/_matrix/client/(api/v1|r0|unstable)/profile/
247+
^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/redact
248+
^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/send
249+
^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/state/
250+
^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/(join|invite|leave|ban|unban|kick)$
251+
^/_matrix/client/(api/v1|r0|v3|unstable)/join/
252+
^/_matrix/client/(api/v1|r0|v3|unstable)/profile/
253253

254254

255255
Additionally, the following REST endpoints can be handled for GET requests:
@@ -261,14 +261,14 @@ room must be routed to the same instance. Additionally, care must be taken to
261261
ensure that the purge history admin API is not used while pagination requests
262262
for the room are in flight:
263263

264-
^/_matrix/client/(api/v1|r0|unstable)/rooms/.*/messages$
264+
^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/messages$
265265

266266
Additionally, the following endpoints should be included if Synapse is configured
267267
to use SSO (you only need to include the ones for whichever SSO provider you're
268268
using):
269269

270270
# for all SSO providers
271-
^/_matrix/client/(api/v1|r0|unstable)/login/sso/redirect
271+
^/_matrix/client/(api/v1|r0|v3|unstable)/login/sso/redirect
272272
^/_synapse/client/pick_idp$
273273
^/_synapse/client/pick_username
274274
^/_synapse/client/new_user_consent$
@@ -281,7 +281,7 @@ using):
281281
^/_synapse/client/saml2/authn_response$
282282

283283
# CAS requests.
284-
^/_matrix/client/(api/v1|r0|unstable)/login/cas/ticket$
284+
^/_matrix/client/(api/v1|r0|v3|unstable)/login/cas/ticket$
285285

286286
Ensure that all SSO logins go to a single process.
287287
For multiple workers not handling the SSO endpoints properly, see
@@ -465,7 +465,7 @@ Note that if a reverse proxy is used , then `/_matrix/media/` must be routed for
465465
Handles searches in the user directory. It can handle REST endpoints matching
466466
the following regular expressions:
467467

468-
^/_matrix/client/(api/v1|r0|unstable)/user_directory/search$
468+
^/_matrix/client/(api/v1|r0|v3|unstable)/user_directory/search$
469469

470470
When using this worker you must also set `update_user_directory: False` in the
471471
shared configuration file to stop the main synapse running background
@@ -477,12 +477,12 @@ Proxies some frequently-requested client endpoints to add caching and remove
477477
load from the main synapse. It can handle REST endpoints matching the following
478478
regular expressions:
479479

480-
^/_matrix/client/(api/v1|r0|unstable)/keys/upload
480+
^/_matrix/client/(api/v1|r0|v3|unstable)/keys/upload
481481

482482
If `use_presence` is False in the homeserver config, it can also handle REST
483483
endpoints matching the following regular expressions:
484484

485-
^/_matrix/client/(api/v1|r0|unstable)/presence/[^/]+/status
485+
^/_matrix/client/(api/v1|r0|v3|unstable)/presence/[^/]+/status
486486

487487
This "stub" presence handler will pass through `GET` request but make the
488488
`PUT` effectively a no-op.

‎synapse/api/urls.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
STATIC_PREFIX = "/_matrix/static"
3131
WEB_CLIENT_PREFIX = "/_matrix/client"
3232
SERVER_KEY_V2_PREFIX = "/_matrix/key/v2"
33-
MEDIA_PREFIX = "/_matrix/media/r0"
33+
MEDIA_R0_PREFIX = "/_matrix/media/r0"
34+
MEDIA_V3_PREFIX = "/_matrix/media/v3"
3435
LEGACY_MEDIA_PREFIX = "/_matrix/media/v1"
3536

3637

‎synapse/app/generic_worker.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
CLIENT_API_PREFIX,
2727
FEDERATION_PREFIX,
2828
LEGACY_MEDIA_PREFIX,
29-
MEDIA_PREFIX,
29+
MEDIA_R0_PREFIX,
30+
MEDIA_V3_PREFIX,
3031
SERVER_KEY_V2_PREFIX,
3132
)
3233
from synapse.app import _base
@@ -338,7 +339,8 @@ def _listen_http(self, listener_config: ListenerConfig) -> None:
338339

339340
resources.update(
340341
{
341-
MEDIA_PREFIX: media_repo,
342+
MEDIA_R0_PREFIX: media_repo,
343+
MEDIA_V3_PREFIX: media_repo,
342344
LEGACY_MEDIA_PREFIX: media_repo,
343345
"/_synapse/admin": admin_resource,
344346
}

‎synapse/app/homeserver.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
from synapse.api.urls import (
3030
FEDERATION_PREFIX,
3131
LEGACY_MEDIA_PREFIX,
32-
MEDIA_PREFIX,
32+
MEDIA_R0_PREFIX,
33+
MEDIA_V3_PREFIX,
3334
SERVER_KEY_V2_PREFIX,
3435
STATIC_PREFIX,
3536
WEB_CLIENT_PREFIX,
@@ -245,7 +246,11 @@ def _configure_named_resource(
245246
if self.config.server.enable_media_repo:
246247
media_repo = self.get_media_repository_resource()
247248
resources.update(
248-
{MEDIA_PREFIX: media_repo, LEGACY_MEDIA_PREFIX: media_repo}
249+
{
250+
MEDIA_R0_PREFIX: media_repo,
251+
MEDIA_V3_PREFIX: media_repo,
252+
LEGACY_MEDIA_PREFIX: media_repo,
253+
}
249254
)
250255
elif name == "media":
251256
raise ConfigError(

0 commit comments

Comments
 (0)
This repository has been archived.