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

Commit 0e99f07

Browse files
Remove support for unstable private read receipts (#13653)
Signed-off-by: Šimon Brandner <[email protected]>
1 parent 737968b commit 0e99f07

File tree

13 files changed

+44
-122
lines changed

13 files changed

+44
-122
lines changed

changelog.d/13653.removal

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove support for unstable [private read receipts](https://github.com/matrix-org/matrix-spec-proposals/pull/2285).

synapse/api/constants.py

-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,6 @@ class GuestAccess:
258258
class ReceiptTypes:
259259
READ: Final = "m.read"
260260
READ_PRIVATE: Final = "m.read.private"
261-
UNSTABLE_READ_PRIVATE: Final = "org.matrix.msc2285.read.private"
262261
FULLY_READ: Final = "m.fully_read"
263262

264263

synapse/config/experimental.py

-3
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ 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 (unstable private read receipts)
36-
self.msc2285_enabled: bool = experimental.get("msc2285_enabled", False)
37-
3835
# MSC3244 (room version capabilities)
3936
self.msc3244_enabled: bool = experimental.get("msc3244_enabled", True)
4037

synapse/handlers/receipts.py

+6-23
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,7 @@ async def received_client_receipt(
163163
if not is_new:
164164
return
165165

166-
if self.federation_sender and receipt_type not in (
167-
ReceiptTypes.READ_PRIVATE,
168-
ReceiptTypes.UNSTABLE_READ_PRIVATE,
169-
):
166+
if self.federation_sender and receipt_type != ReceiptTypes.READ_PRIVATE:
170167
await self.federation_sender.send_read_receipt(receipt)
171168

172169

@@ -206,38 +203,24 @@ def filter_out_private_receipts(
206203
for event_id, orig_event_content in room.get("content", {}).items():
207204
event_content = orig_event_content
208205
# If there are private read receipts, additional logic is necessary.
209-
if (
210-
ReceiptTypes.READ_PRIVATE in event_content
211-
or ReceiptTypes.UNSTABLE_READ_PRIVATE in event_content
212-
):
206+
if ReceiptTypes.READ_PRIVATE in event_content:
213207
# Make a copy without private read receipts to avoid leaking
214208
# other user's private read receipts..
215209
event_content = {
216210
receipt_type: receipt_value
217211
for receipt_type, receipt_value in event_content.items()
218-
if receipt_type
219-
not in (
220-
ReceiptTypes.READ_PRIVATE,
221-
ReceiptTypes.UNSTABLE_READ_PRIVATE,
222-
)
212+
if receipt_type != ReceiptTypes.READ_PRIVATE
223213
}
224214

225215
# Copy the current user's private read receipt from the
226216
# original content, if it exists.
227-
user_private_read_receipt = orig_event_content.get(
228-
ReceiptTypes.READ_PRIVATE, {}
229-
).get(user_id, None)
217+
user_private_read_receipt = orig_event_content[
218+
ReceiptTypes.READ_PRIVATE
219+
].get(user_id, None)
230220
if user_private_read_receipt:
231221
event_content[ReceiptTypes.READ_PRIVATE] = {
232222
user_id: user_private_read_receipt
233223
}
234-
user_unstable_private_read_receipt = orig_event_content.get(
235-
ReceiptTypes.UNSTABLE_READ_PRIVATE, {}
236-
).get(user_id, None)
237-
if user_unstable_private_read_receipt:
238-
event_content[ReceiptTypes.UNSTABLE_READ_PRIVATE] = {
239-
user_id: user_unstable_private_read_receipt
240-
}
241224

242225
# Include the event if there is at least one non-private read
243226
# receipt or the current user has a private read receipt.

synapse/replication/tcp/client.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -416,10 +416,7 @@ async def _on_new_receipts(
416416
if not self._is_mine_id(receipt.user_id):
417417
continue
418418
# Private read receipts never get sent over federation.
419-
if receipt.receipt_type in (
420-
ReceiptTypes.READ_PRIVATE,
421-
ReceiptTypes.UNSTABLE_READ_PRIVATE,
422-
):
419+
if receipt.receipt_type == ReceiptTypes.READ_PRIVATE:
423420
continue
424421
receipt_info = ReadReceipt(
425422
receipt.room_id,

synapse/rest/client/notifications.py

-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ async def on_GET(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
6262
[
6363
ReceiptTypes.READ,
6464
ReceiptTypes.READ_PRIVATE,
65-
ReceiptTypes.UNSTABLE_READ_PRIVATE,
6665
],
6766
)
6867

synapse/rest/client/read_marker.py

-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ def __init__(self, hs: "HomeServer"):
4545
ReceiptTypes.FULLY_READ,
4646
ReceiptTypes.READ_PRIVATE,
4747
}
48-
if hs.config.experimental.msc2285_enabled:
49-
self._known_receipt_types.add(ReceiptTypes.UNSTABLE_READ_PRIVATE)
5048

5149
async def on_POST(
5250
self, request: SynapseRequest, room_id: str

synapse/rest/client/receipts.py

-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ def __init__(self, hs: "HomeServer"):
4949
ReceiptTypes.READ_PRIVATE,
5050
ReceiptTypes.FULLY_READ,
5151
}
52-
if hs.config.experimental.msc2285_enabled:
53-
self._known_receipt_types.add(ReceiptTypes.UNSTABLE_READ_PRIVATE)
5452

5553
async def on_POST(
5654
self, request: SynapseRequest, room_id: str, receipt_type: str, event_id: str

synapse/rest/client/versions.py

-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ def on_GET(self, request: Request) -> Tuple[int, JsonDict]:
9595
"org.matrix.msc3026.busy_presence": self.config.experimental.msc3026_enabled,
9696
# Supports receiving private read receipts as per MSC2285
9797
"org.matrix.msc2285.stable": True, # TODO: Remove when MSC2285 becomes a part of the spec
98-
"org.matrix.msc2285": self.config.experimental.msc2285_enabled,
9998
# Supports filtering of /publicRooms by room type as per MSC3827
10099
"org.matrix.msc3827.stable": True,
101100
# Adds support for importing historical messages as per MSC2716

synapse/storage/databases/main/event_push_actions.py

-2
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,6 @@ def _get_unread_counts_by_receipt_txn(
274274
receipt_types=(
275275
ReceiptTypes.READ,
276276
ReceiptTypes.READ_PRIVATE,
277-
ReceiptTypes.UNSTABLE_READ_PRIVATE,
278277
),
279278
)
280279

@@ -468,7 +467,6 @@ def _get_receipts_by_room_txn(
468467
(
469468
ReceiptTypes.READ,
470469
ReceiptTypes.READ_PRIVATE,
471-
ReceiptTypes.UNSTABLE_READ_PRIVATE,
472470
),
473471
)
474472

tests/handlers/test_receipts.py

+13-35
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
from copy import deepcopy
1616
from typing import List
1717

18-
from parameterized import parameterized
19-
2018
from synapse.api.constants import EduTypes, ReceiptTypes
2119
from synapse.types import JsonDict
2220

@@ -27,16 +25,13 @@ class ReceiptsTestCase(unittest.HomeserverTestCase):
2725
def prepare(self, reactor, clock, hs):
2826
self.event_source = hs.get_event_sources().sources.receipt
2927

30-
@parameterized.expand(
31-
[ReceiptTypes.READ_PRIVATE, ReceiptTypes.UNSTABLE_READ_PRIVATE]
32-
)
33-
def test_filters_out_private_receipt(self, receipt_type: str) -> None:
28+
def test_filters_out_private_receipt(self) -> None:
3429
self._test_filters_private(
3530
[
3631
{
3732
"content": {
3833
"$1435641916114394fHBLK:matrix.org": {
39-
receipt_type: {
34+
ReceiptTypes.READ_PRIVATE: {
4035
"@rikj:jki.re": {
4136
"ts": 1436451550453,
4237
}
@@ -50,18 +45,13 @@ def test_filters_out_private_receipt(self, receipt_type: str) -> None:
5045
[],
5146
)
5247

53-
@parameterized.expand(
54-
[ReceiptTypes.READ_PRIVATE, ReceiptTypes.UNSTABLE_READ_PRIVATE]
55-
)
56-
def test_filters_out_private_receipt_and_ignores_rest(
57-
self, receipt_type: str
58-
) -> None:
48+
def test_filters_out_private_receipt_and_ignores_rest(self) -> None:
5949
self._test_filters_private(
6050
[
6151
{
6252
"content": {
6353
"$1dgdgrd5641916114394fHBLK:matrix.org": {
64-
receipt_type: {
54+
ReceiptTypes.READ_PRIVATE: {
6555
"@rikj:jki.re": {
6656
"ts": 1436451550453,
6757
},
@@ -94,18 +84,15 @@ def test_filters_out_private_receipt_and_ignores_rest(
9484
],
9585
)
9686

97-
@parameterized.expand(
98-
[ReceiptTypes.READ_PRIVATE, ReceiptTypes.UNSTABLE_READ_PRIVATE]
99-
)
10087
def test_filters_out_event_with_only_private_receipts_and_ignores_the_rest(
101-
self, receipt_type: str
88+
self,
10289
) -> None:
10390
self._test_filters_private(
10491
[
10592
{
10693
"content": {
10794
"$14356419edgd14394fHBLK:matrix.org": {
108-
receipt_type: {
95+
ReceiptTypes.READ_PRIVATE: {
10996
"@rikj:jki.re": {
11097
"ts": 1436451550453,
11198
},
@@ -175,18 +162,15 @@ def test_handles_empty_event(self) -> None:
175162
],
176163
)
177164

178-
@parameterized.expand(
179-
[ReceiptTypes.READ_PRIVATE, ReceiptTypes.UNSTABLE_READ_PRIVATE]
180-
)
181165
def test_filters_out_receipt_event_with_only_private_receipt_and_ignores_rest(
182-
self, receipt_type: str
166+
self,
183167
) -> None:
184168
self._test_filters_private(
185169
[
186170
{
187171
"content": {
188172
"$14356419edgd14394fHBLK:matrix.org": {
189-
receipt_type: {
173+
ReceiptTypes.READ_PRIVATE: {
190174
"@rikj:jki.re": {
191175
"ts": 1436451550453,
192176
},
@@ -262,16 +246,13 @@ def test_handles_string_data(self) -> None:
262246
],
263247
)
264248

265-
@parameterized.expand(
266-
[ReceiptTypes.READ_PRIVATE, ReceiptTypes.UNSTABLE_READ_PRIVATE]
267-
)
268-
def test_leaves_our_private_and_their_public(self, receipt_type: str) -> None:
249+
def test_leaves_our_private_and_their_public(self) -> None:
269250
self._test_filters_private(
270251
[
271252
{
272253
"content": {
273254
"$1dgdgrd5641916114394fHBLK:matrix.org": {
274-
receipt_type: {
255+
ReceiptTypes.READ_PRIVATE: {
275256
"@me:server.org": {
276257
"ts": 1436451550453,
277258
},
@@ -296,7 +277,7 @@ def test_leaves_our_private_and_their_public(self, receipt_type: str) -> None:
296277
{
297278
"content": {
298279
"$1dgdgrd5641916114394fHBLK:matrix.org": {
299-
receipt_type: {
280+
ReceiptTypes.READ_PRIVATE: {
300281
"@me:server.org": {
301282
"ts": 1436451550453,
302283
},
@@ -319,16 +300,13 @@ def test_leaves_our_private_and_their_public(self, receipt_type: str) -> None:
319300
],
320301
)
321302

322-
@parameterized.expand(
323-
[ReceiptTypes.READ_PRIVATE, ReceiptTypes.UNSTABLE_READ_PRIVATE]
324-
)
325-
def test_we_do_not_mutate(self, receipt_type: str) -> None:
303+
def test_we_do_not_mutate(self) -> None:
326304
"""Ensure the input values are not modified."""
327305
events = [
328306
{
329307
"content": {
330308
"$1435641916114394fHBLK:matrix.org": {
331-
receipt_type: {
309+
ReceiptTypes.READ_PRIVATE: {
332310
"@rikj:jki.re": {
333311
"ts": 1436451550453,
334312
}

0 commit comments

Comments
 (0)