0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-11-16 15:01:23 +01:00

Drop support for v2_alpha API prefix (#5190)

This commit is contained in:
Richard van der Hoff 2019-05-15 17:37:46 +01:00 committed by GitHub
parent 1757e2d7c3
commit 5f027a315f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 21 additions and 26 deletions

1
changelog.d/5190.feature Normal file
View file

@ -0,0 +1 @@
Drop support for the undocumented /_matrix/client/v2_alpha API prefix.

View file

@ -22,8 +22,7 @@ from six.moves.urllib.parse import urlencode
from synapse.config import ConfigError from synapse.config import ConfigError
CLIENT_PREFIX = "/_matrix/client/api/v1" CLIENT_API_PREFIX = "/_matrix/client"
CLIENT_V2_ALPHA_PREFIX = "/_matrix/client/v2_alpha"
FEDERATION_PREFIX = "/_matrix/federation" FEDERATION_PREFIX = "/_matrix/federation"
FEDERATION_V1_PREFIX = FEDERATION_PREFIX + "/v1" FEDERATION_V1_PREFIX = FEDERATION_PREFIX + "/v1"
FEDERATION_V2_PREFIX = FEDERATION_PREFIX + "/v2" FEDERATION_V2_PREFIX = FEDERATION_PREFIX + "/v2"

View file

@ -19,7 +19,7 @@
import logging import logging
import re import re
from synapse.api.urls import CLIENT_PREFIX from synapse.api.urls import CLIENT_API_PREFIX
from synapse.http.servlet import RestServlet from synapse.http.servlet import RestServlet
from synapse.rest.client.transactions import HttpTransactionCache from synapse.rest.client.transactions import HttpTransactionCache
@ -36,12 +36,12 @@ def client_path_patterns(path_regex, releases=(0,), include_in_unstable=True):
Returns: Returns:
SRE_Pattern SRE_Pattern
""" """
patterns = [re.compile("^" + CLIENT_PREFIX + path_regex)] patterns = [re.compile("^" + CLIENT_API_PREFIX + "/api/v1" + path_regex)]
if include_in_unstable: if include_in_unstable:
unstable_prefix = CLIENT_PREFIX.replace("/api/v1", "/unstable") unstable_prefix = CLIENT_API_PREFIX + "/unstable"
patterns.append(re.compile("^" + unstable_prefix + path_regex)) patterns.append(re.compile("^" + unstable_prefix + path_regex))
for release in releases: for release in releases:
new_prefix = CLIENT_PREFIX.replace("/api/v1", "/r%d" % release) new_prefix = CLIENT_API_PREFIX + "/r%d" % (release,)
patterns.append(re.compile("^" + new_prefix + path_regex)) patterns.append(re.compile("^" + new_prefix + path_regex))
return patterns return patterns

View file

@ -21,13 +21,12 @@ import re
from twisted.internet import defer from twisted.internet import defer
from synapse.api.errors import InteractiveAuthIncompleteError from synapse.api.errors import InteractiveAuthIncompleteError
from synapse.api.urls import CLIENT_V2_ALPHA_PREFIX from synapse.api.urls import CLIENT_API_PREFIX
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
def client_v2_patterns(path_regex, releases=(0,), def client_v2_patterns(path_regex, releases=(0,),
v2_alpha=True,
unstable=True): unstable=True):
"""Creates a regex compiled client path with the correct client path """Creates a regex compiled client path with the correct client path
prefix. prefix.
@ -39,13 +38,11 @@ def client_v2_patterns(path_regex, releases=(0,),
SRE_Pattern SRE_Pattern
""" """
patterns = [] patterns = []
if v2_alpha:
patterns.append(re.compile("^" + CLIENT_V2_ALPHA_PREFIX + path_regex))
if unstable: if unstable:
unstable_prefix = CLIENT_V2_ALPHA_PREFIX.replace("/v2_alpha", "/unstable") unstable_prefix = CLIENT_API_PREFIX + "/unstable"
patterns.append(re.compile("^" + unstable_prefix + path_regex)) patterns.append(re.compile("^" + unstable_prefix + path_regex))
for release in releases: for release in releases:
new_prefix = CLIENT_V2_ALPHA_PREFIX.replace("/v2_alpha", "/r%d" % release) new_prefix = CLIENT_API_PREFIX + "/r%d" % (release,)
patterns.append(re.compile("^" + new_prefix + path_regex)) patterns.append(re.compile("^" + new_prefix + path_regex))
return patterns return patterns

View file

@ -19,7 +19,7 @@ from twisted.internet import defer
from synapse.api.constants import LoginType from synapse.api.constants import LoginType
from synapse.api.errors import SynapseError from synapse.api.errors import SynapseError
from synapse.api.urls import CLIENT_V2_ALPHA_PREFIX from synapse.api.urls import CLIENT_API_PREFIX
from synapse.http.server import finish_request from synapse.http.server import finish_request
from synapse.http.servlet import RestServlet, parse_string from synapse.http.servlet import RestServlet, parse_string
@ -139,8 +139,8 @@ class AuthRestServlet(RestServlet):
if stagetype == LoginType.RECAPTCHA: if stagetype == LoginType.RECAPTCHA:
html = RECAPTCHA_TEMPLATE % { html = RECAPTCHA_TEMPLATE % {
'session': session, 'session': session,
'myurl': "%s/auth/%s/fallback/web" % ( 'myurl': "%s/r0/auth/%s/fallback/web" % (
CLIENT_V2_ALPHA_PREFIX, LoginType.RECAPTCHA CLIENT_API_PREFIX, LoginType.RECAPTCHA
), ),
'sitekey': self.hs.config.recaptcha_public_key, 'sitekey': self.hs.config.recaptcha_public_key,
} }
@ -159,8 +159,8 @@ class AuthRestServlet(RestServlet):
self.hs.config.public_baseurl, self.hs.config.public_baseurl,
self.hs.config.user_consent_version, self.hs.config.user_consent_version,
), ),
'myurl': "%s/auth/%s/fallback/web" % ( 'myurl': "%s/r0/auth/%s/fallback/web" % (
CLIENT_V2_ALPHA_PREFIX, LoginType.TERMS CLIENT_API_PREFIX, LoginType.TERMS
), ),
} }
html_bytes = html.encode("utf8") html_bytes = html.encode("utf8")
@ -203,8 +203,8 @@ class AuthRestServlet(RestServlet):
else: else:
html = RECAPTCHA_TEMPLATE % { html = RECAPTCHA_TEMPLATE % {
'session': session, 'session': session,
'myurl': "%s/auth/%s/fallback/web" % ( 'myurl': "%s/r0/auth/%s/fallback/web" % (
CLIENT_V2_ALPHA_PREFIX, LoginType.RECAPTCHA CLIENT_API_PREFIX, LoginType.RECAPTCHA
), ),
'sitekey': self.hs.config.recaptcha_public_key, 'sitekey': self.hs.config.recaptcha_public_key,
} }
@ -240,8 +240,8 @@ class AuthRestServlet(RestServlet):
self.hs.config.public_baseurl, self.hs.config.public_baseurl,
self.hs.config.user_consent_version, self.hs.config.user_consent_version,
), ),
'myurl': "%s/auth/%s/fallback/web" % ( 'myurl': "%s/r0/auth/%s/fallback/web" % (
CLIENT_V2_ALPHA_PREFIX, LoginType.TERMS CLIENT_API_PREFIX, LoginType.TERMS
), ),
} }
html_bytes = html.encode("utf8") html_bytes = html.encode("utf8")

View file

@ -30,7 +30,7 @@ logger = logging.getLogger(__name__)
class DevicesRestServlet(RestServlet): class DevicesRestServlet(RestServlet):
PATTERNS = client_v2_patterns("/devices$", v2_alpha=False) PATTERNS = client_v2_patterns("/devices$")
def __init__(self, hs): def __init__(self, hs):
""" """
@ -56,7 +56,7 @@ class DeleteDevicesRestServlet(RestServlet):
API for bulk deletion of devices. Accepts a JSON object with a devices API for bulk deletion of devices. Accepts a JSON object with a devices
key which lists the device_ids to delete. Requires user interactive auth. key which lists the device_ids to delete. Requires user interactive auth.
""" """
PATTERNS = client_v2_patterns("/delete_devices", v2_alpha=False) PATTERNS = client_v2_patterns("/delete_devices")
def __init__(self, hs): def __init__(self, hs):
super(DeleteDevicesRestServlet, self).__init__() super(DeleteDevicesRestServlet, self).__init__()
@ -95,7 +95,7 @@ class DeleteDevicesRestServlet(RestServlet):
class DeviceRestServlet(RestServlet): class DeviceRestServlet(RestServlet):
PATTERNS = client_v2_patterns("/devices/(?P<device_id>[^/]*)$", v2_alpha=False) PATTERNS = client_v2_patterns("/devices/(?P<device_id>[^/]*)$")
def __init__(self, hs): def __init__(self, hs):
""" """

View file

@ -50,7 +50,6 @@ class RoomUpgradeRestServlet(RestServlet):
PATTERNS = client_v2_patterns( PATTERNS = client_v2_patterns(
# /rooms/$roomid/upgrade # /rooms/$roomid/upgrade
"/rooms/(?P<room_id>[^/]*)/upgrade$", "/rooms/(?P<room_id>[^/]*)/upgrade$",
v2_alpha=False,
) )
def __init__(self, hs): def __init__(self, hs):

View file

@ -29,7 +29,6 @@ logger = logging.getLogger(__name__)
class SendToDeviceRestServlet(servlet.RestServlet): class SendToDeviceRestServlet(servlet.RestServlet):
PATTERNS = client_v2_patterns( PATTERNS = client_v2_patterns(
"/sendToDevice/(?P<message_type>[^/]*)/(?P<txn_id>[^/]*)$", "/sendToDevice/(?P<message_type>[^/]*)/(?P<txn_id>[^/]*)$",
v2_alpha=False
) )
def __init__(self, hs): def __init__(self, hs):