22
22
Iterable ,
23
23
List ,
24
24
Optional ,
25
- Set ,
26
25
Tuple ,
27
26
cast ,
28
27
)
@@ -117,33 +116,6 @@ def get_max_receipt_stream_id(self) -> int:
117
116
"""Get the current max stream ID for receipts stream"""
118
117
return self ._receipts_id_gen .get_current_token ()
119
118
120
- @cached ()
121
- async def get_users_with_read_receipts_in_room (self , room_id : str ) -> Set [str ]:
122
- receipts = await self .get_receipts_for_room (room_id , ReceiptTypes .READ )
123
- return {r ["user_id" ] for r in receipts }
124
-
125
- @cached ()
126
- async def get_receipts_for_room (
127
- self , room_id : str , receipt_type : str
128
- ) -> List [Dict [str , Any ]]:
129
- """
130
- Fetch the event IDs for the latest receipt for all users in a room with the given receipt type.
131
-
132
- Args:
133
- room_id: The room ID to fetch the receipt for.
134
- receipt_type: The receipt type to fetch.
135
-
136
- Returns:
137
- A list of dictionaries, one for each user ID. Each dictionary
138
- contains a user ID and the event ID of that user's latest receipt.
139
- """
140
- return await self .db_pool .simple_select_list (
141
- table = "receipts_linearized" ,
142
- keyvalues = {"room_id" : room_id , "receipt_type" : receipt_type },
143
- retcols = ("user_id" , "event_id" ),
144
- desc = "get_receipts_for_room" ,
145
- )
146
-
147
119
async def get_last_receipt_event_id_for_user (
148
120
self , user_id : str , room_id : str , receipt_types : Iterable [str ]
149
121
) -> Optional [str ]:
@@ -599,23 +571,6 @@ def get_all_updated_receipts_txn(
599
571
"get_all_updated_receipts" , get_all_updated_receipts_txn
600
572
)
601
573
602
- def _invalidate_get_users_with_receipts_in_room (
603
- self , room_id : str , receipt_type : str , user_id : str
604
- ) -> None :
605
- if receipt_type != ReceiptTypes .READ :
606
- return
607
-
608
- res = self .get_users_with_read_receipts_in_room .cache .get_immediate (
609
- room_id , None , update_metrics = False
610
- )
611
-
612
- if res and user_id in res :
613
- # We'd only be adding to the set, so no point invalidating if the
614
- # user is already there
615
- return
616
-
617
- self .get_users_with_read_receipts_in_room .invalidate ((room_id ,))
618
-
619
574
def invalidate_caches_for_receipt (
620
575
self , room_id : str , receipt_type : str , user_id : str
621
576
) -> None :
@@ -624,8 +579,6 @@ def invalidate_caches_for_receipt(
624
579
self ._get_last_receipt_event_id_for_user .invalidate (
625
580
(user_id , room_id , receipt_type )
626
581
)
627
- self ._invalidate_get_users_with_receipts_in_room (room_id , receipt_type , user_id )
628
- self .get_receipts_for_room .invalidate ((room_id , receipt_type ))
629
582
630
583
def process_replication_rows (
631
584
self ,
@@ -842,13 +795,6 @@ def insert_graph_receipt_txn(
842
795
) -> None :
843
796
assert self ._can_write_to_receipts
844
797
845
- txn .call_after (self .get_receipts_for_room .invalidate , (room_id , receipt_type ))
846
- txn .call_after (
847
- self ._invalidate_get_users_with_receipts_in_room ,
848
- room_id ,
849
- receipt_type ,
850
- user_id ,
851
- )
852
798
txn .call_after (
853
799
self ._get_receipts_for_user_with_orderings .invalidate ,
854
800
(user_id , receipt_type ),
0 commit comments