Skip to content
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

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

turt2live
Copy link
Member

matrix-org/matrix-spec-proposals#4151 has finished FCP.

See #17373 for unstable endpoint removal

@turt2live turt2live marked this pull request as ready for review June 29, 2024 00:08
@turt2live turt2live requested a review from a team as a code owner June 29, 2024 00:08
Comment on lines +202 to +205
ReportRoomRestServlet(hs).register(http_server)

if hs.config.experimental.msc4151_enabled:
ReportRoomRestServlet(hs).register(http_server)
UnstableReportRoomRestServlet(hs).register(http_server)
Copy link
Member

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,
	    )

Copy link
Member Author

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?

Copy link
Member

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$")
Copy link
Member

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.

Copy link
Member Author

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 :(

Copy link
Member

@anoadragon453 anoadragon453 Jul 11, 2024

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",).

@anoadragon453 anoadragon453 removed their request for review July 15, 2024 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants