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

Commit 9ae0253

Browse files
Use private instead of hidden in MSC2285 related code. (#12635)
1 parent f90d381 commit 9ae0253

File tree

7 files changed

+26
-25
lines changed

7 files changed

+26
-25
lines changed

changelog.d/12635.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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.

synapse/config/experimental.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def read_config(self, config: JsonDict, **kwargs: Any) -> None:
3232
# MSC2716 (importing historical messages)
3333
self.msc2716_enabled: bool = experimental.get("msc2716_enabled", False)
3434

35-
# MSC2285 (hidden read receipts)
35+
# MSC2285 (private read receipts)
3636
self.msc2285_enabled: bool = experimental.get("msc2285_enabled", False)
3737

3838
# MSC3244 (room version capabilities)

synapse/handlers/initial_sync.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ async def _snapshot_all_rooms(
143143
to_key=int(now_token.receipt_key),
144144
)
145145
if self.hs.config.experimental.msc2285_enabled:
146-
receipt = ReceiptEventSource.filter_out_hidden(receipt, user_id)
146+
receipt = ReceiptEventSource.filter_out_private(receipt, user_id)
147147

148148
tags_by_room = await self.store.get_tags_for_user(user_id)
149149

@@ -449,7 +449,7 @@ async def get_receipts() -> List[JsonDict]:
449449
if not receipts:
450450
return []
451451
if self.hs.config.experimental.msc2285_enabled:
452-
receipts = ReceiptEventSource.filter_out_hidden(receipts, user_id)
452+
receipts = ReceiptEventSource.filter_out_private(receipts, user_id)
453453
return receipts
454454

455455
presence, receipts, (messages, token) = await make_deferred_yieldable(

synapse/handlers/receipts.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def __init__(self, hs: "HomeServer"):
165165
self.config = hs.config
166166

167167
@staticmethod
168-
def filter_out_hidden(events: List[JsonDict], user_id: str) -> List[JsonDict]:
168+
def filter_out_private(events: List[JsonDict], user_id: str) -> List[JsonDict]:
169169
"""
170170
This method takes in what is returned by
171171
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]:
175175

176176
visible_events = []
177177

178-
# filter out hidden receipts the user shouldn't see
178+
# filter out private receipts the user shouldn't see
179179
for event in events:
180180
content = event.get("content", {})
181181
new_event = event.copy()
@@ -223,7 +223,7 @@ async def get_new_events(
223223
)
224224

225225
if self.config.experimental.msc2285_enabled:
226-
events = ReceiptEventSource.filter_out_hidden(events, user.to_string())
226+
events = ReceiptEventSource.filter_out_private(events, user.to_string())
227227

228228
return events, to_key
229229

synapse/rest/client/versions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def on_GET(self, request: Request) -> Tuple[int, JsonDict]:
9393
"io.element.e2ee_forced.trusted_private": self.e2ee_forced_trusted_private,
9494
# Supports the busy presence state described in MSC3026.
9595
"org.matrix.msc3026.busy_presence": self.config.experimental.msc3026_enabled,
96-
# Supports receiving hidden read receipts as per MSC2285
96+
# Supports receiving private read receipts as per MSC2285
9797
"org.matrix.msc2285": self.config.experimental.msc2285_enabled,
9898
# Adds support for importing historical messages as per MSC2716
9999
"org.matrix.msc2716": self.config.experimental.msc2716_enabled,

tests/handlers/test_receipts.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ class ReceiptsTestCase(unittest.HomeserverTestCase):
2525
def prepare(self, reactor, clock, hs):
2626
self.event_source = hs.get_event_sources().sources.receipt
2727

28-
def test_filters_out_hidden_receipt(self):
29-
self._test_filters_hidden(
28+
def test_filters_out_private_receipt(self):
29+
self._test_filters_private(
3030
[
3131
{
3232
"content": {
@@ -45,8 +45,8 @@ def test_filters_out_hidden_receipt(self):
4545
[],
4646
)
4747

48-
def test_filters_out_hidden_receipt_and_ignores_rest(self):
49-
self._test_filters_hidden(
48+
def test_filters_out_private_receipt_and_ignores_rest(self):
49+
self._test_filters_private(
5050
[
5151
{
5252
"content": {
@@ -84,8 +84,8 @@ def test_filters_out_hidden_receipt_and_ignores_rest(self):
8484
],
8585
)
8686

87-
def test_filters_out_event_with_only_hidden_receipts_and_ignores_the_rest(self):
88-
self._test_filters_hidden(
87+
def test_filters_out_event_with_only_private_receipts_and_ignores_the_rest(self):
88+
self._test_filters_private(
8989
[
9090
{
9191
"content": {
@@ -126,7 +126,7 @@ def test_filters_out_event_with_only_hidden_receipts_and_ignores_the_rest(self):
126126
)
127127

128128
def test_handles_missing_content_of_m_read(self):
129-
self._test_filters_hidden(
129+
self._test_filters_private(
130130
[
131131
{
132132
"content": {
@@ -162,7 +162,7 @@ def test_handles_missing_content_of_m_read(self):
162162
)
163163

164164
def test_handles_empty_event(self):
165-
self._test_filters_hidden(
165+
self._test_filters_private(
166166
[
167167
{
168168
"content": {
@@ -196,8 +196,8 @@ def test_handles_empty_event(self):
196196
],
197197
)
198198

199-
def test_filters_out_receipt_event_with_only_hidden_receipt_and_ignores_rest(self):
200-
self._test_filters_hidden(
199+
def test_filters_out_receipt_event_with_only_private_receipt_and_ignores_rest(self):
200+
self._test_filters_private(
201201
[
202202
{
203203
"content": {
@@ -249,7 +249,7 @@ def test_handles_string_data(self):
249249
Context: https://github.com/matrix-org/synapse/issues/10603
250250
"""
251251

252-
self._test_filters_hidden(
252+
self._test_filters_private(
253253
[
254254
{
255255
"content": {
@@ -278,8 +278,8 @@ def test_handles_string_data(self):
278278
],
279279
)
280280

281-
def test_leaves_our_hidden_and_their_public(self):
282-
self._test_filters_hidden(
281+
def test_leaves_our_private_and_their_public(self):
282+
self._test_filters_private(
283283
[
284284
{
285285
"content": {
@@ -332,9 +332,9 @@ def test_leaves_our_hidden_and_their_public(self):
332332
],
333333
)
334334

335-
def _test_filters_hidden(
335+
def _test_filters_private(
336336
self, events: List[JsonDict], expected_output: List[JsonDict]
337337
):
338-
"""Tests that the _filter_out_hidden returns the expected output"""
339-
filtered_events = self.event_source.filter_out_hidden(events, "@me:server.org")
338+
"""Tests that the _filter_out_private returns the expected output"""
339+
filtered_events = self.event_source.filter_out_private(events, "@me:server.org")
340340
self.assertEqual(filtered_events, expected_output)

tests/rest/client/test_sync.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ def prepare(self, reactor: MemoryReactor, clock: Clock, hs: HomeServer) -> None:
407407
self.helper.join(room=self.room_id, user=self.user2, tok=self.tok2)
408408

409409
@override_config({"experimental_features": {"msc2285_enabled": True}})
410-
def test_hidden_read_receipts(self) -> None:
410+
def test_private_read_receipts(self) -> None:
411411
# Send a message as the first user
412412
res = self.helper.send(self.room_id, body="hello", tok=self.tok)
413413

@@ -639,7 +639,7 @@ def test_unread_counts(self) -> None:
639639
# Check that the unread counter is back to 0.
640640
self._check_unread_count(0)
641641

642-
# Check that hidden read receipts don't break unread counts
642+
# Check that private read receipts don't break unread counts
643643
res = self.helper.send(self.room_id, "hello", tok=self.tok2)
644644
self._check_unread_count(1)
645645

0 commit comments

Comments
 (0)