19
19
from enum import Enum
20
20
from typing import Any , Dict , List , Optional , Tuple
21
21
22
- from synapse .api .constants import EventTypes
22
+ from synapse .api .constants import EventTypes , JoinRules
23
23
from synapse .api .errors import StoreError
24
24
from synapse .api .room_versions import RoomVersion , RoomVersions
25
25
from synapse .storage ._base import SQLBaseStore , db_to_json
@@ -177,11 +177,13 @@ def _count_public_rooms_txn(txn):
177
177
INNER JOIN room_stats_current USING (room_id)
178
178
WHERE
179
179
(
180
- join_rules = 'public' OR history_visibility = 'world_readable'
180
+ join_rules = 'public' OR join_rules = '%(knock_join_rule)s'
181
+ OR history_visibility = 'world_readable'
181
182
)
182
183
AND joined_members > 0
183
184
""" % {
184
- "published_sql" : published_sql
185
+ "published_sql" : published_sql ,
186
+ "knock_join_rule" : JoinRules .KNOCK ,
185
187
}
186
188
187
189
txn .execute (sql , query_args )
@@ -303,15 +305,16 @@ async def get_largest_public_rooms(
303
305
sql = """
304
306
SELECT
305
307
room_id, name, topic, canonical_alias, joined_members,
306
- avatar, history_visibility, joined_members, guest_access
308
+ avatar, history_visibility, guest_access, join_rules
307
309
FROM (
308
310
%(published_sql)s
309
311
) published
310
312
INNER JOIN room_stats_state USING (room_id)
311
313
INNER JOIN room_stats_current USING (room_id)
312
314
WHERE
313
315
(
314
- join_rules = 'public' OR history_visibility = 'world_readable'
316
+ join_rules = 'public' OR join_rules = '%(knock_join_rule)s'
317
+ OR history_visibility = 'world_readable'
315
318
)
316
319
AND joined_members > 0
317
320
%(where_clause)s
@@ -320,6 +323,7 @@ async def get_largest_public_rooms(
320
323
"published_sql" : published_sql ,
321
324
"where_clause" : where_clause ,
322
325
"dir" : "DESC" if forwards else "ASC" ,
326
+ "knock_join_rule" : JoinRules .KNOCK ,
323
327
}
324
328
325
329
if limit is not None :
0 commit comments