diff options
-rw-r--r-- | changelog.d/12632.misc | 1 | ||||
-rw-r--r-- | synapse/storage/databases/main/receipts.py | 54 |
2 files changed, 1 insertions, 54 deletions
diff --git a/changelog.d/12632.misc b/changelog.d/12632.misc new file mode 100644 index 0000000000..9e4ba79c79 --- /dev/null +++ b/changelog.d/12632.misc @@ -0,0 +1 @@ +Remove unused code related to receipts. diff --git a/synapse/storage/databases/main/receipts.py b/synapse/storage/databases/main/receipts.py index 9e3d838eab..d035969a31 100644 --- a/synapse/storage/databases/main/receipts.py +++ b/synapse/storage/databases/main/receipts.py @@ -22,7 +22,6 @@ from typing import ( Iterable, List, Optional, - Set, Tuple, cast, ) @@ -117,33 +116,6 @@ class ReceiptsWorkerStore(SQLBaseStore): """Get the current max stream ID for receipts stream""" return self._receipts_id_gen.get_current_token() - @cached() - async def get_users_with_read_receipts_in_room(self, room_id: str) -> Set[str]: - receipts = await self.get_receipts_for_room(room_id, ReceiptTypes.READ) - return {r["user_id"] for r in receipts} - - @cached() - async def get_receipts_for_room( - self, room_id: str, receipt_type: str - ) -> List[Dict[str, Any]]: - """ - Fetch the event IDs for the latest receipt for all users in a room with the given receipt type. - - Args: - room_id: The room ID to fetch the receipt for. - receipt_type: The receipt type to fetch. - - Returns: - A list of dictionaries, one for each user ID. Each dictionary - contains a user ID and the event ID of that user's latest receipt. - """ - return await self.db_pool.simple_select_list( - table="receipts_linearized", - keyvalues={"room_id": room_id, "receipt_type": receipt_type}, - retcols=("user_id", "event_id"), - desc="get_receipts_for_room", - ) - async def get_last_receipt_event_id_for_user( self, user_id: str, room_id: str, receipt_types: Iterable[str] ) -> Optional[str]: @@ -599,23 +571,6 @@ class ReceiptsWorkerStore(SQLBaseStore): "get_all_updated_receipts", get_all_updated_receipts_txn ) - def _invalidate_get_users_with_receipts_in_room( - self, room_id: str, receipt_type: str, user_id: str - ) -> None: - if receipt_type != ReceiptTypes.READ: - return - - res = self.get_users_with_read_receipts_in_room.cache.get_immediate( - room_id, None, update_metrics=False - ) - - if res and user_id in res: - # We'd only be adding to the set, so no point invalidating if the - # user is already there - return - - self.get_users_with_read_receipts_in_room.invalidate((room_id,)) - def invalidate_caches_for_receipt( self, room_id: str, receipt_type: str, user_id: str ) -> None: @@ -624,8 +579,6 @@ class ReceiptsWorkerStore(SQLBaseStore): self._get_last_receipt_event_id_for_user.invalidate( (user_id, room_id, receipt_type) ) - self._invalidate_get_users_with_receipts_in_room(room_id, receipt_type, user_id) - self.get_receipts_for_room.invalidate((room_id, receipt_type)) def process_replication_rows( self, @@ -842,13 +795,6 @@ class ReceiptsWorkerStore(SQLBaseStore): ) -> None: assert self._can_write_to_receipts - txn.call_after(self.get_receipts_for_room.invalidate, (room_id, receipt_type)) - txn.call_after( - self._invalidate_get_users_with_receipts_in_room, - room_id, - receipt_type, - user_id, - ) txn.call_after( self._get_receipts_for_user_with_orderings.invalidate, (user_id, receipt_type), |