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

Commit 9689cfe

Browse files
committed
Remove the limited flag.
1 parent 13324cf commit 9689cfe

File tree

3 files changed

+16
-34
lines changed

3 files changed

+16
-34
lines changed

synapse/handlers/relations.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,11 @@ async def _get_bundled_aggregation_for_event(
190190
# while others need more processing during serialization.
191191
aggregations = BundledAggregations()
192192

193-
annotations, limited = await self._main_store.get_aggregation_groups_for_event(
193+
annotations = await self._main_store.get_aggregation_groups_for_event(
194194
event_id, room_id
195195
)
196196
if annotations:
197-
aggregations.annotations = {"chunk": annotations, "limited": limited}
197+
aggregations.annotations = {"chunk": annotations}
198198

199199
references = await self._main_store.get_relations_for_event(
200200
event_id, event, room_id, RelationTypes.REFERENCE, direction="f"

synapse/storage/databases/main/relations.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ async def event_is_target_of_relation(self, parent_id: str) -> bool:
251251
@cached(tree=True)
252252
async def get_aggregation_groups_for_event(
253253
self, event_id: str, room_id: str, limit: int = 5
254-
) -> Tuple[List[JsonDict], bool]:
254+
) -> List[JsonDict]:
255255
"""Get a list of annotations on the event, grouped by event type and
256256
aggregation key, sorted by count.
257257
@@ -264,18 +264,15 @@ async def get_aggregation_groups_for_event(
264264
limit: Only fetch the `limit` groups.
265265
266266
Returns:
267-
A tuple of:
268-
A list of groups of annotations that match. Each row is a dict with
269-
`type`, `key` and `count` fields.
270-
271-
A boolean indicating if the result is limited (i.e. if there are
272-
additional results to return).
267+
List of groups of annotations that match. Each row is a dict with
268+
`type`, `key` and `count` fields.
273269
"""
274270

275-
where_args: List[Union[str, int]] = [
271+
where_args = [
276272
event_id,
277273
room_id,
278274
RelationTypes.ANNOTATION,
275+
limit,
279276
]
280277

281278
sql = """
@@ -290,13 +287,10 @@ async def get_aggregation_groups_for_event(
290287

291288
def _get_aggregation_groups_for_event_txn(
292289
txn: LoggingTransaction,
293-
) -> Tuple[List[JsonDict], bool]:
294-
txn.execute(sql, where_args + [limit + 1])
295-
296-
events = [{"type": row[0], "key": row[1], "count": row[2]} for row in txn]
297-
limited = len(events) > limit
290+
) -> List[JsonDict]:
291+
txn.execute(sql, where_args)
298292

299-
return events[:limit], limited
293+
return [{"type": row[0], "key": row[1], "count": row[2]} for row in txn]
300294

301295
return await self.db_pool.runInteraction(
302296
"get_aggregation_groups_for_event", _get_aggregation_groups_for_event_txn

tests/rest/client/test_relations.py

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -984,8 +984,7 @@ def assert_annotations(bundled_aggregations: JsonDict) -> None:
984984
"chunk": [
985985
{"type": "m.reaction", "key": "a", "count": 2},
986986
{"type": "m.reaction", "key": "b", "count": 1},
987-
],
988-
"limited": False,
987+
]
989988
},
990989
bundled_aggregations,
991990
)
@@ -1081,8 +1080,7 @@ def test_aggregation_get_event_for_thread(self) -> None:
10811080
channel.json_body["unsigned"].get("m.relations"),
10821081
{
10831082
RelationTypes.ANNOTATION: {
1084-
"chunk": [{"count": 1, "key": "a", "type": "m.reaction"}],
1085-
"limited": False,
1083+
"chunk": [{"count": 1, "key": "a", "type": "m.reaction"}]
10861084
},
10871085
},
10881086
)
@@ -1101,8 +1099,7 @@ def test_aggregation_get_event_for_thread(self) -> None:
11011099
thread_message["unsigned"].get("m.relations"),
11021100
{
11031101
RelationTypes.ANNOTATION: {
1104-
"chunk": [{"count": 1, "key": "a", "type": "m.reaction"}],
1105-
"limited": False,
1102+
"chunk": [{"count": 1, "key": "a", "type": "m.reaction"}]
11061103
},
11071104
},
11081105
)
@@ -1262,10 +1259,7 @@ def test_redact_relation_annotation(self) -> None:
12621259
self.assertCountEqual(event_ids, [to_redact_event_id, unredacted_event_id])
12631260
self.assertEquals(
12641261
relations["m.annotation"],
1265-
{
1266-
"chunk": [{"type": "m.reaction", "key": "a", "count": 2}],
1267-
"limited": False,
1268-
},
1262+
{"chunk": [{"type": "m.reaction", "key": "a", "count": 2}]},
12691263
)
12701264

12711265
# Redact one of the reactions.
@@ -1277,10 +1271,7 @@ def test_redact_relation_annotation(self) -> None:
12771271
self.assertEquals(event_ids, [unredacted_event_id])
12781272
self.assertEquals(
12791273
relations["m.annotation"],
1280-
{
1281-
"chunk": [{"type": "m.reaction", "key": "a", "count": 1}],
1282-
"limited": False,
1283-
},
1274+
{"chunk": [{"type": "m.reaction", "key": "a", "count": 1}]},
12841275
)
12851276

12861277
def test_redact_relation_thread(self) -> None:
@@ -1397,10 +1388,7 @@ def test_redact_parent_annotation(self) -> None:
13971388
self.assertEquals(event_ids, [related_event_id])
13981389
self.assertEquals(
13991390
relations["m.annotation"],
1400-
{
1401-
"chunk": [{"type": "m.reaction", "key": "👍", "count": 1}],
1402-
"limited": False,
1403-
},
1391+
{"chunk": [{"type": "m.reaction", "key": "👍", "count": 1}]},
14041392
)
14051393

14061394
@unittest.override_config({"experimental_features": {"msc3440_enabled": True}})

0 commit comments

Comments
 (0)