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

Commit 81d9f2a

Browse files
author
David Robertson
authored
Fixes to MSC3787 implementation (#12858)
1 parent 042e479 commit 81d9f2a

File tree

4 files changed

+21
-20
lines changed

4 files changed

+21
-20
lines changed

changelog.d/12858.bugfix

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix [MSC3878](https://github.com/matrix-org/matrix-spec-proposals/pull/3787) rooms being omitted from room directory, room summary and space hierarchy responses.

scripts-dev/complement.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ docker build -t matrixdotorg/synapse -f "docker/Dockerfile" .
4545

4646
extra_test_args=()
4747

48-
test_tags="synapse_blacklist,msc2716,msc3030"
48+
test_tags="synapse_blacklist,msc2716,msc3030,msc3787"
4949

5050
# If we're using workers, modify the docker files slightly.
5151
if [[ -n "$WORKERS" ]]; then

synapse/handlers/room_summary.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,8 @@ async def _is_remote_room_accessible(
662662
# The API doesn't return the room version so assume that a
663663
# join rule of knock is valid.
664664
if (
665-
room.get("join_rules") in (JoinRules.PUBLIC, JoinRules.KNOCK)
665+
room.get("join_rules")
666+
in (JoinRules.PUBLIC, JoinRules.KNOCK, JoinRules.KNOCK_RESTRICTED)
666667
or room.get("world_readable") is True
667668
):
668669
return True

synapse/storage/databases/main/room.py

+17-18
Original file line numberDiff line numberDiff line change
@@ -233,24 +233,23 @@ def _count_public_rooms_txn(txn: LoggingTransaction) -> int:
233233
UNION SELECT room_id from appservice_room_list
234234
"""
235235

236-
sql = """
236+
sql = f"""
237237
SELECT
238238
COUNT(*)
239239
FROM (
240-
%(published_sql)s
240+
{published_sql}
241241
) published
242242
INNER JOIN room_stats_state USING (room_id)
243243
INNER JOIN room_stats_current USING (room_id)
244244
WHERE
245245
(
246-
join_rules = 'public' OR join_rules = '%(knock_join_rule)s'
246+
join_rules = '{JoinRules.PUBLIC}'
247+
OR join_rules = '{JoinRules.KNOCK}'
248+
OR join_rules = '{JoinRules.KNOCK_RESTRICTED}'
247249
OR history_visibility = 'world_readable'
248250
)
249251
AND joined_members > 0
250-
""" % {
251-
"published_sql": published_sql,
252-
"knock_join_rule": JoinRules.KNOCK,
253-
}
252+
"""
254253

255254
txn.execute(sql, query_args)
256255
return cast(Tuple[int], txn.fetchone())[0]
@@ -369,29 +368,29 @@ async def get_largest_public_rooms(
369368
if where_clauses:
370369
where_clause = " AND " + " AND ".join(where_clauses)
371370

372-
sql = """
371+
dir = "DESC" if forwards else "ASC"
372+
sql = f"""
373373
SELECT
374374
room_id, name, topic, canonical_alias, joined_members,
375375
avatar, history_visibility, guest_access, join_rules
376376
FROM (
377-
%(published_sql)s
377+
{published_sql}
378378
) published
379379
INNER JOIN room_stats_state USING (room_id)
380380
INNER JOIN room_stats_current USING (room_id)
381381
WHERE
382382
(
383-
join_rules = 'public' OR join_rules = '%(knock_join_rule)s'
383+
join_rules = '{JoinRules.PUBLIC}'
384+
OR join_rules = '{JoinRules.KNOCK}'
385+
OR join_rules = '{JoinRules.KNOCK_RESTRICTED}'
384386
OR history_visibility = 'world_readable'
385387
)
386388
AND joined_members > 0
387-
%(where_clause)s
388-
ORDER BY joined_members %(dir)s, room_id %(dir)s
389-
""" % {
390-
"published_sql": published_sql,
391-
"where_clause": where_clause,
392-
"dir": "DESC" if forwards else "ASC",
393-
"knock_join_rule": JoinRules.KNOCK,
394-
}
389+
{where_clause}
390+
ORDER BY
391+
joined_members {dir},
392+
room_id {dir}
393+
"""
395394

396395
if limit is not None:
397396
query_args.append(limit)

0 commit comments

Comments
 (0)