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

Commit ee848f6

Browse files
author
David Robertson
committed
Include knock_restricted rooms in room directory, summary, and spaces heirarchy
Missed in #12623.
1 parent f5a3ea8 commit ee848f6

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

synapse/handlers/room_summary.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ 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") in (JoinRules.PUBLIC, JoinRules.KNOCK, JoinRules.KNOCK_RESTRICTED)
666666
or room.get("world_readable") is True
667667
):
668668
return True

synapse/storage/databases/main/room.py

Lines changed: 17 additions & 18 deletions
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)