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

Commit ef8a9d7

Browse files
committed
Inline a helper used only once.
1 parent 6be806b commit ef8a9d7

File tree

1 file changed

+11
-41
lines changed

1 file changed

+11
-41
lines changed

synapse/handlers/relations.py

+11-41
Original file line numberDiff line numberDiff line change
@@ -172,40 +172,6 @@ async def get_relations(
172172

173173
return return_value
174174

175-
async def get_relations_for_event(
176-
self,
177-
event_id: str,
178-
event: EventBase,
179-
room_id: str,
180-
relation_type: str,
181-
ignored_users: FrozenSet[str] = frozenset(),
182-
) -> List[_RelatedEvent]:
183-
"""Get a list of events which relate to an event, ordered by topological ordering.
184-
185-
Args:
186-
event_id: Fetch events that relate to this event ID.
187-
event: The matching EventBase to event_id.
188-
room_id: The room the event belongs to.
189-
relation_type: The type of relation.
190-
ignored_users: The users ignored by the requesting user.
191-
192-
Returns:
193-
List of event IDs that match relations requested. The rows are of
194-
the form `{"event_id": "..."}`.
195-
"""
196-
197-
# Call the underlying storage method, which is cached.
198-
related_events, _ = await self._main_store.get_relations_for_event(
199-
event_id, event, room_id, relation_type, direction="f"
200-
)
201-
202-
# Filter out ignored users and convert to the expected format.
203-
related_events = [
204-
event for event in related_events if event.sender not in ignored_users
205-
]
206-
207-
return related_events
208-
209175
async def redact_events_related_to(
210176
self,
211177
requester: Requester,
@@ -443,14 +409,18 @@ async def _get_threads_for_events(
443409
if event is None:
444410
continue
445411

446-
potential_events = await self.get_relations_for_event(
447-
event_id,
448-
event,
449-
room_id,
450-
RelationTypes.THREAD,
451-
ignored_users,
412+
# Attempt to find another event to use as the latest event.
413+
potential_events, _ = await self._main_store.get_relations_for_event(
414+
event_id, event, room_id, RelationTypes.THREAD, direction="f"
452415
)
453416

417+
# Filter out ignored users.
418+
potential_events = [
419+
event
420+
for event in potential_events
421+
if event.sender not in ignored_users
422+
]
423+
454424
# If all found events are from ignored users, do not include
455425
# a summary of the thread.
456426
if not potential_events:
@@ -620,7 +590,7 @@ async def get_threads(
620590
room_id, requester, allow_departed_users=True
621591
)
622592

623-
# Note that ignored users are not passed into get_relations_for_event
593+
# Note that ignored users are not passed into get_threads
624594
# below. Ignored users are handled in filter_events_for_client (and by
625595
# not passing them in here we should get a better cache hit rate).
626596
thread_roots, next_batch = await self._main_store.get_threads(

0 commit comments

Comments
 (0)