From e497b7f2901aa7a566f3e800b29b22d0a9d330bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Thu, 5 May 2022 09:41:32 +0200 Subject: [PATCH 1/4] Add changelog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- changelog.d/12635.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/12635.misc diff --git a/changelog.d/12635.misc b/changelog.d/12635.misc new file mode 100644 index 000000000000..299d092c3456 --- /dev/null +++ b/changelog.d/12635.misc @@ -0,0 +1 @@ +Use `private` instead of `hidden` in [MSC2285](https://github.com/matrix-org/matrix-spec-proposals/pull/2285) related code. From ad21252c86d5b9916488f750fb9f8bf2d371c60c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Thu, 5 May 2022 09:38:11 +0200 Subject: [PATCH 2/4] Use `private` instead of `hidden` in MSC2285 related code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- synapse/config/experimental.py | 2 +- synapse/handlers/initial_sync.py | 4 ++-- synapse/handlers/receipts.py | 6 +++--- synapse/rest/client/versions.py | 2 +- tests/handlers/test_receipts.py | 32 ++++++++++++++++---------------- tests/rest/client/test_sync.py | 4 ++-- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/synapse/config/experimental.py b/synapse/config/experimental.py index 421ed7481baf..abed5e7edb3a 100644 --- a/synapse/config/experimental.py +++ b/synapse/config/experimental.py @@ -32,7 +32,7 @@ def read_config(self, config: JsonDict, **kwargs: Any) -> None: # MSC2716 (importing historical messages) self.msc2716_enabled: bool = experimental.get("msc2716_enabled", False) - # MSC2285 (hidden read receipts) + # MSC2285 (private read receipts) self.msc2285_enabled: bool = experimental.get("msc2285_enabled", False) # MSC3244 (room version capabilities) diff --git a/synapse/handlers/initial_sync.py b/synapse/handlers/initial_sync.py index a7db8feb57eb..7b94770f9722 100644 --- a/synapse/handlers/initial_sync.py +++ b/synapse/handlers/initial_sync.py @@ -143,7 +143,7 @@ async def _snapshot_all_rooms( to_key=int(now_token.receipt_key), ) if self.hs.config.experimental.msc2285_enabled: - receipt = ReceiptEventSource.filter_out_hidden(receipt, user_id) + receipt = ReceiptEventSource.filter_out_private(receipt, user_id) tags_by_room = await self.store.get_tags_for_user(user_id) @@ -449,7 +449,7 @@ async def get_receipts() -> List[JsonDict]: if not receipts: return [] if self.hs.config.experimental.msc2285_enabled: - receipts = ReceiptEventSource.filter_out_hidden(receipts, user_id) + receipts = ReceiptEventSource.filter_out_private(receipts, user_id) return receipts presence, receipts, (messages, token) = await make_deferred_yieldable( diff --git a/synapse/handlers/receipts.py b/synapse/handlers/receipts.py index ae41fd674e13..43d615357b3c 100644 --- a/synapse/handlers/receipts.py +++ b/synapse/handlers/receipts.py @@ -165,7 +165,7 @@ def __init__(self, hs: "HomeServer"): self.config = hs.config @staticmethod - def filter_out_hidden(events: List[JsonDict], user_id: str) -> List[JsonDict]: + def filter_out_private(events: List[JsonDict], user_id: str) -> List[JsonDict]: """ This method takes in what is returned by get_linearized_receipts_for_rooms() and goes through read receipts @@ -175,7 +175,7 @@ def filter_out_hidden(events: List[JsonDict], user_id: str) -> List[JsonDict]: visible_events = [] - # filter out hidden receipts the user shouldn't see + # filter out private receipts the user shouldn't see for event in events: content = event.get("content", {}) new_event = event.copy() @@ -223,7 +223,7 @@ async def get_new_events( ) if self.config.experimental.msc2285_enabled: - events = ReceiptEventSource.filter_out_hidden(events, user.to_string()) + events = ReceiptEventSource.filter_out_private(events, user.to_string()) return events, to_key diff --git a/synapse/rest/client/versions.py b/synapse/rest/client/versions.py index bfc1d4ee0829..c1bd775fece4 100644 --- a/synapse/rest/client/versions.py +++ b/synapse/rest/client/versions.py @@ -93,7 +93,7 @@ def on_GET(self, request: Request) -> Tuple[int, JsonDict]: "io.element.e2ee_forced.trusted_private": self.e2ee_forced_trusted_private, # Supports the busy presence state described in MSC3026. "org.matrix.msc3026.busy_presence": self.config.experimental.msc3026_enabled, - # Supports receiving hidden read receipts as per MSC2285 + # Supports receiving private read receipts as per MSC2285 "org.matrix.msc2285": self.config.experimental.msc2285_enabled, # Adds support for importing historical messages as per MSC2716 "org.matrix.msc2716": self.config.experimental.msc2716_enabled, diff --git a/tests/handlers/test_receipts.py b/tests/handlers/test_receipts.py index c12a9120f029..0482a1ea34fb 100644 --- a/tests/handlers/test_receipts.py +++ b/tests/handlers/test_receipts.py @@ -25,8 +25,8 @@ class ReceiptsTestCase(unittest.HomeserverTestCase): def prepare(self, reactor, clock, hs): self.event_source = hs.get_event_sources().sources.receipt - def test_filters_out_hidden_receipt(self): - self._test_filters_hidden( + def test_filters_out_private_receipt(self): + self._test_filters_private( [ { "content": { @@ -45,8 +45,8 @@ def test_filters_out_hidden_receipt(self): [], ) - def test_filters_out_hidden_receipt_and_ignores_rest(self): - self._test_filters_hidden( + def test_filters_out_private_receipt_and_ignores_rest(self): + self._test_filters_private( [ { "content": { @@ -84,8 +84,8 @@ def test_filters_out_hidden_receipt_and_ignores_rest(self): ], ) - def test_filters_out_event_with_only_hidden_receipts_and_ignores_the_rest(self): - self._test_filters_hidden( + def test_filters_out_event_with_only_private_receipts_and_ignores_the_rest(self): + self._test_filters_private( [ { "content": { @@ -126,7 +126,7 @@ def test_filters_out_event_with_only_hidden_receipts_and_ignores_the_rest(self): ) def test_handles_missing_content_of_m_read(self): - self._test_filters_hidden( + self._test_filters_private( [ { "content": { @@ -162,7 +162,7 @@ def test_handles_missing_content_of_m_read(self): ) def test_handles_empty_event(self): - self._test_filters_hidden( + self._test_filters_private( [ { "content": { @@ -196,8 +196,8 @@ def test_handles_empty_event(self): ], ) - def test_filters_out_receipt_event_with_only_hidden_receipt_and_ignores_rest(self): - self._test_filters_hidden( + def test_filters_out_receipt_event_with_only_private_receipt_and_ignores_rest(self): + self._test_filters_private( [ { "content": { @@ -249,7 +249,7 @@ def test_handles_string_data(self): Context: https://github.com/matrix-org/synapse/issues/10603 """ - self._test_filters_hidden( + self._test_filters_private( [ { "content": { @@ -278,8 +278,8 @@ def test_handles_string_data(self): ], ) - def test_leaves_our_hidden_and_their_public(self): - self._test_filters_hidden( + def test_leaves_our_private_and_their_public(self): + self._test_filters_private( [ { "content": { @@ -332,9 +332,9 @@ def test_leaves_our_hidden_and_their_public(self): ], ) - def _test_filters_hidden( + def _test_filters_private( self, events: List[JsonDict], expected_output: List[JsonDict] ): - """Tests that the _filter_out_hidden returns the expected output""" - filtered_events = self.event_source.filter_out_hidden(events, "@me:server.org") + """Tests that the _filter_out_private returns the expected output""" + filtered_events = self.event_source.filter_out_private(events, "@me:server.org") self.assertEqual(filtered_events, expected_output) diff --git a/tests/rest/client/test_sync.py b/tests/rest/client/test_sync.py index 67c94dd18fbd..010833764957 100644 --- a/tests/rest/client/test_sync.py +++ b/tests/rest/client/test_sync.py @@ -407,7 +407,7 @@ def prepare(self, reactor: MemoryReactor, clock: Clock, hs: HomeServer) -> None: self.helper.join(room=self.room_id, user=self.user2, tok=self.tok2) @override_config({"experimental_features": {"msc2285_enabled": True}}) - def test_hidden_read_receipts(self) -> None: + def test_private_read_receipts(self) -> None: # Send a message as the first user res = self.helper.send(self.room_id, body="hello", tok=self.tok) @@ -639,7 +639,7 @@ def test_unread_counts(self) -> None: # Check that the unread counter is back to 0. self._check_unread_count(0) - # Check that hidden read receipts don't break unread counts + # Check that private read receipts don't break unread counts res = self.helper.send(self.room_id, "hello", tok=self.tok2) self._check_unread_count(1) From 32298663087b90023086fd952feb253273c603fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Thu, 5 May 2022 14:04:29 +0200 Subject: [PATCH 3/4] Match changelog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- changelog.d/12635.misc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/12635.misc b/changelog.d/12635.misc index 299d092c3456..cd5c45029ee1 100644 --- a/changelog.d/12635.misc +++ b/changelog.d/12635.misc @@ -1 +1 @@ -Use `private` instead of `hidden` in [MSC2285](https://github.com/matrix-org/matrix-spec-proposals/pull/2285) related code. +Implement [changes](https://github.com/matrix-org/matrix-spec-proposals/pull/2285/commits/4a77139249c2e830aec3c7d6bd5501a514d1cc27) to [MSC2285 (hidden read receipts)](https://github.com/matrix-org/matrix-spec-proposals/pull/2285). Contributed by @SimonBrandner. From 3e24bae6de7be8bd742092bc535f1f937cc805eb Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Thu, 5 May 2022 08:05:53 -0400 Subject: [PATCH 4/4] Rename changelog file to match #12168. --- changelog.d/{12635.misc => 12635.feature} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changelog.d/{12635.misc => 12635.feature} (100%) diff --git a/changelog.d/12635.misc b/changelog.d/12635.feature similarity index 100% rename from changelog.d/12635.misc rename to changelog.d/12635.feature