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

Move the dir parameter for /relations behind an experimental flag. #12984

Merged
merged 2 commits into from
Jun 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/12984.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Move [MSC3715](https://github.com/matrix-org/matrix-spec-proposals/pull/3715) behind an experimental config flag.
3 changes: 3 additions & 0 deletions synapse/config/experimental.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,6 @@ def read_config(self, config: JsonDict, **kwargs: Any) -> None:

# MSC3772: A push rule for mutual relations.
self.msc3772_enabled: bool = experimental.get("msc3772_enabled", False)

# MSC3715: dir param on /relations.
self.msc3715_enabled: bool = experimental.get("msc3715_enabled", False)
13 changes: 10 additions & 3 deletions synapse/rest/client/relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def __init__(self, hs: "HomeServer"):
self.auth = hs.get_auth()
self.store = hs.get_datastores().main
self._relations_handler = hs.get_relations_handler()
self._msc3715_enabled = hs.config.experimental.msc3715_enabled

async def on_GET(
self,
Expand All @@ -55,9 +56,15 @@ async def on_GET(
requester = await self.auth.get_user_by_req(request, allow_guest=True)

limit = parse_integer(request, "limit", default=5)
direction = parse_string(
request, "org.matrix.msc3715.dir", default="b", allowed_values=["f", "b"]
)
if self._msc3715_enabled:
direction = parse_string(
request,
"org.matrix.msc3715.dir",
default="b",
allowed_values=["f", "b"],
)
else:
direction = "b"
from_token_str = parse_string(request, "from")
to_token_str = parse_string(request, "to")

Expand Down
1 change: 1 addition & 0 deletions tests/rest/client/test_relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,7 @@ def test_background_update(self) -> None:


class RelationPaginationTestCase(BaseRelationsTestCase):
@unittest.override_config({"experimental_features": {"msc3715_enabled": True}})
def test_basic_paginate_relations(self) -> None:
"""Tests that calling pagination API correctly the latest relations."""
channel = self._send_relation(RelationTypes.ANNOTATION, "m.reaction", "a")
Expand Down