This repository was archived by the owner on Apr 26, 2024. It is now read-only.
File tree 2 files changed +20
-5
lines changed
2 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -273,13 +273,28 @@ async def _get_threads_for_events(
273
273
# Fetch thread summaries.
274
274
summaries = await self ._main_store .get_thread_summaries (event_ids )
275
275
276
- # Only fetch participated for a limited selection based on what had
276
+ # Only fetch whether the current user has participated in a thread based
277
+ # on which returned for a limited selection based on what had
277
278
# summaries.
278
279
thread_event_ids = [
279
280
event_id for event_id , summary in summaries .items () if summary
280
281
]
281
- participated = await self ._main_store .get_threads_participated (
282
- thread_event_ids , user_id
282
+
283
+ # Preseed thread participation with whether the requester send the event.
284
+ participated = {
285
+ event_id : events_by_id [event_id ].sender == user_id
286
+ for event_id in thread_event_ids
287
+ }
288
+ # Check other events against the database.
289
+ participated .update (
290
+ await self ._main_store .get_threads_participated (
291
+ [
292
+ event_id
293
+ for event_id in thread_event_ids
294
+ if not participated [event_id ]
295
+ ],
296
+ user_id ,
297
+ )
283
298
)
284
299
285
300
# Then subtract off the results for any ignored users.
Original file line number Diff line number Diff line change @@ -1073,7 +1073,7 @@ def assert_thread(bundled_aggregations: JsonDict) -> None:
1073
1073
return assert_thread
1074
1074
1075
1075
# A user which has sent the root event or replied has participated.
1076
- self ._test_bundled_aggregations (RelationTypes .THREAD , _gen_assert (True ), 10 )
1076
+ self ._test_bundled_aggregations (RelationTypes .THREAD , _gen_assert (True ), 9 )
1077
1077
# Note that this re-uses some cached values, so the total number of
1078
1078
# queries is much smaller.
1079
1079
self ._test_bundled_aggregations (
@@ -1131,7 +1131,7 @@ def assert_thread(bundled_aggregations: JsonDict) -> None:
1131
1131
bundled_aggregations ["latest_event" ].get ("unsigned" ),
1132
1132
)
1133
1133
1134
- self ._test_bundled_aggregations (RelationTypes .THREAD , assert_thread , 10 )
1134
+ self ._test_bundled_aggregations (RelationTypes .THREAD , assert_thread , 9 )
1135
1135
1136
1136
def test_nested_thread (self ) -> None :
1137
1137
"""
You can’t perform that action at this time.
0 commit comments