diff --git a/synapse/api/constants.py b/synapse/api/constants.py index 6cc96bbc5399..5d68796f7bc1 100644 --- a/synapse/api/constants.py +++ b/synapse/api/constants.py @@ -258,7 +258,6 @@ class GuestAccess: class ReceiptTypes: READ: Final = "m.read" READ_PRIVATE: Final = "m.read.private" - READ_PRIVATE_UNSTABLE: Final = "org.matrix.msc2285.read.private" FULLY_READ: Final = "m.fully_read" diff --git a/synapse/handlers/receipts.py b/synapse/handlers/receipts.py index e5c516695815..d2bdb9c8be79 100644 --- a/synapse/handlers/receipts.py +++ b/synapse/handlers/receipts.py @@ -203,27 +203,20 @@ def filter_out_private_receipts( for event_id, orig_event_content in room.get("content", {}).items(): event_content = orig_event_content # If there are private read receipts, additional logic is necessary. - if ( - ReceiptTypes.READ_PRIVATE in event_content - or ReceiptTypes.READ_PRIVATE_UNSTABLE in event_content - ): + if ReceiptTypes.READ_PRIVATE in event_content: # Make a copy without private read receipts to avoid leaking # other user's private read receipts.. event_content = { receipt_type: receipt_value for receipt_type, receipt_value in event_content.items() - if receipt_type - not in ( - ReceiptTypes.READ_PRIVATE, - ReceiptTypes.READ_PRIVATE_UNSTABLE, - ) + if receipt_type != ReceiptTypes.READ_PRIVATE } # Copy the current user's private read receipt from the # original content, if it exists. - user_private_read_receipt = orig_event_content.get( - ReceiptTypes.READ_PRIVATE, {} - ).get(user_id, None) + user_private_read_receipt = orig_event_content[ + ReceiptTypes.READ_PRIVATE + ].get(user_id, None) if user_private_read_receipt: event_content[ReceiptTypes.READ_PRIVATE] = { user_id: user_private_read_receipt diff --git a/synapse/storage/schema/main/delta/72/04remove_unstable_private_read_receipts.sql b/synapse/storage/schema/main/delta/72/04remove_unstable_private_read_receipts.sql new file mode 100644 index 000000000000..409dc918d53d --- /dev/null +++ b/synapse/storage/schema/main/delta/72/04remove_unstable_private_read_receipts.sql @@ -0,0 +1,17 @@ +/* Copyright 2022 The Matrix.org Foundation C.I.C + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +DELETE FROM receipts_linearized WHERE receipt_type = 'org.matrix.msc2285.read.private'; +DELETE FROM receipts_graph WHERE receipt_type = 'org.matrix.msc2285.read.private'; diff --git a/tests/handlers/test_receipts.py b/tests/handlers/test_receipts.py index 6fcbf20666b3..a95868b5c055 100644 --- a/tests/handlers/test_receipts.py +++ b/tests/handlers/test_receipts.py @@ -296,26 +296,6 @@ def test_leaves_our_private_and_their_public(self): ], ) - def test_filters_out_unstable_private_receipt(self): - self._test_filters_private( - [ - { - "content": { - "$1435641916114394fHBLK:matrix.org": { - "org.matrix.msc2285.read.private": { - "@rikj:jki.re": { - "ts": 1436451550453, - } - } - } - }, - "room_id": "!jEsUZKDJdhlrceRyVU:example.org", - "type": EduTypes.RECEIPT, - } - ], - [], - ) - def test_we_do_not_mutate(self): """Ensure the input values are not modified.""" events = [