-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support & use stable endpoints for MSC4151 #17374
base: develop
Are you sure you want to change the base?
Conversation
ReportRoomRestServlet(hs).register(http_server) | ||
|
||
if hs.config.experimental.msc4151_enabled: | ||
ReportRoomRestServlet(hs).register(http_server) | ||
UnstableReportRoomRestServlet(hs).register(http_server) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given we don't expect the functionality to differ between the stable and unstable versions of this endpoint, you can avoid the code duplication by setting PATTERNS
from within the __init__
method of ReportRoomRestServlet
based on the experimental config value:
class ReportRoomRestServlet(RestServlet):
# Note: Top-level PATTERNS definition removed
def __init__(self, hs: "HomeServer"):
super().__init__()
self.hs = hs
self.auth = hs.get_auth()
self.clock = hs.get_clock()
self.store = hs.get_datastores().main
self.PATTERNS = client_patterns(
"/rooms/(?P<room_id>[^/]*)/report$",
releases=("v3",),
# TODO: Remove the unstable variant after 2-3 releases
# https://github.com/element-hq/synapse/issues/17373
unstable=hs.config.experimental.msc4151_enabled,
v1=False,
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually, how would this know to use unstable/org.matrix.msc4151
as its version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, true. In that case you could instead do:
class ReportRoomRestServlet(RestServlet):
PATTERNS = client_patterns(
"/rooms/(?P<room_id>[^/]*)/report$"),
releases=("v3",),
unstable=False,
v1=False,
)
def __init__(self, hs: "HomeServer"):
super().__init__()
self.hs = hs
self.auth = hs.get_auth()
self.clock = hs.get_clock()
self.store = hs.get_datastores().main
# TODO: Remove the unstable variant after 2-3 releases
# https://github.com/element-hq/synapse/issues/17373
if hs.config.experimental.msc4151_enabled:
self.PATTERNS.append(
re.compile(
f"^{CLIENT_API_PREFIX}/unstable/org.matrix.msc4151"
"/rooms/(?P<room_id>[^/]*)/report$"
)
)
Introduced by MSC4151: https://github.com/matrix-org/matrix-spec-proposals/pull/4151 | ||
""" | ||
|
||
PATTERNS = client_patterns("/rooms/(?P<room_id>[^/]*)/report$") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that the default value for the releases
argument is (r0, v3)
. I assume we only want to make this available on v3
?
Note the unstable endpoint was available on r0
as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For cleanliness it should be v3 only - is there a common way to declare that? It's not great that the endpoint was on r0 all this time too :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The usual method is releases=("v3",)
.
matrix-org/matrix-spec-proposals#4151 has finished FCP.
See #17373 for unstable endpoint removal