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

Use private instead of hidden in MSC2285 related code #12635

Merged
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/12635.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
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.
2 changes: 1 addition & 1 deletion synapse/config/experimental.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions synapse/handlers/initial_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions synapse/handlers/receipts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion synapse/rest/client/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
32 changes: 16 additions & 16 deletions tests/handlers/test_receipts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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)
4 changes: 2 additions & 2 deletions tests/rest/client/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down