mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-13 06:42:20 -04:00
Fixes to MSC3787 implementation (#12858)
This commit is contained in:
parent
042e47970b
commit
81d9f2a8e9
4 changed files with 21 additions and 20 deletions
|
@ -233,24 +233,23 @@ class RoomWorkerStore(CacheInvalidationWorkerStore):
|
|||
UNION SELECT room_id from appservice_room_list
|
||||
"""
|
||||
|
||||
sql = """
|
||||
sql = f"""
|
||||
SELECT
|
||||
COUNT(*)
|
||||
FROM (
|
||||
%(published_sql)s
|
||||
{published_sql}
|
||||
) published
|
||||
INNER JOIN room_stats_state USING (room_id)
|
||||
INNER JOIN room_stats_current USING (room_id)
|
||||
WHERE
|
||||
(
|
||||
join_rules = 'public' OR join_rules = '%(knock_join_rule)s'
|
||||
join_rules = '{JoinRules.PUBLIC}'
|
||||
OR join_rules = '{JoinRules.KNOCK}'
|
||||
OR join_rules = '{JoinRules.KNOCK_RESTRICTED}'
|
||||
OR history_visibility = 'world_readable'
|
||||
)
|
||||
AND joined_members > 0
|
||||
""" % {
|
||||
"published_sql": published_sql,
|
||||
"knock_join_rule": JoinRules.KNOCK,
|
||||
}
|
||||
"""
|
||||
|
||||
txn.execute(sql, query_args)
|
||||
return cast(Tuple[int], txn.fetchone())[0]
|
||||
|
@ -369,29 +368,29 @@ class RoomWorkerStore(CacheInvalidationWorkerStore):
|
|||
if where_clauses:
|
||||
where_clause = " AND " + " AND ".join(where_clauses)
|
||||
|
||||
sql = """
|
||||
dir = "DESC" if forwards else "ASC"
|
||||
sql = f"""
|
||||
SELECT
|
||||
room_id, name, topic, canonical_alias, joined_members,
|
||||
avatar, history_visibility, guest_access, join_rules
|
||||
FROM (
|
||||
%(published_sql)s
|
||||
{published_sql}
|
||||
) published
|
||||
INNER JOIN room_stats_state USING (room_id)
|
||||
INNER JOIN room_stats_current USING (room_id)
|
||||
WHERE
|
||||
(
|
||||
join_rules = 'public' OR join_rules = '%(knock_join_rule)s'
|
||||
join_rules = '{JoinRules.PUBLIC}'
|
||||
OR join_rules = '{JoinRules.KNOCK}'
|
||||
OR join_rules = '{JoinRules.KNOCK_RESTRICTED}'
|
||||
OR history_visibility = 'world_readable'
|
||||
)
|
||||
AND joined_members > 0
|
||||
%(where_clause)s
|
||||
ORDER BY joined_members %(dir)s, room_id %(dir)s
|
||||
""" % {
|
||||
"published_sql": published_sql,
|
||||
"where_clause": where_clause,
|
||||
"dir": "DESC" if forwards else "ASC",
|
||||
"knock_join_rule": JoinRules.KNOCK,
|
||||
}
|
||||
{where_clause}
|
||||
ORDER BY
|
||||
joined_members {dir},
|
||||
room_id {dir}
|
||||
"""
|
||||
|
||||
if limit is not None:
|
||||
query_args.append(limit)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue