Fixes to MSC3787 implementation (#12858)
parent
042e47970b
commit
81d9f2a8e9
|
@ -0,0 +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.
|
|
@ -45,7 +45,7 @@ docker build -t matrixdotorg/synapse -f "docker/Dockerfile" .
|
||||||
|
|
||||||
extra_test_args=()
|
extra_test_args=()
|
||||||
|
|
||||||
test_tags="synapse_blacklist,msc2716,msc3030"
|
test_tags="synapse_blacklist,msc2716,msc3030,msc3787"
|
||||||
|
|
||||||
# If we're using workers, modify the docker files slightly.
|
# If we're using workers, modify the docker files slightly.
|
||||||
if [[ -n "$WORKERS" ]]; then
|
if [[ -n "$WORKERS" ]]; then
|
||||||
|
|
|
@ -662,7 +662,8 @@ class RoomSummaryHandler:
|
||||||
# The API doesn't return the room version so assume that a
|
# The API doesn't return the room version so assume that a
|
||||||
# join rule of knock is valid.
|
# join rule of knock is valid.
|
||||||
if (
|
if (
|
||||||
room.get("join_rules") in (JoinRules.PUBLIC, JoinRules.KNOCK)
|
room.get("join_rules")
|
||||||
|
in (JoinRules.PUBLIC, JoinRules.KNOCK, JoinRules.KNOCK_RESTRICTED)
|
||||||
or room.get("world_readable") is True
|
or room.get("world_readable") is True
|
||||||
):
|
):
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -233,24 +233,23 @@ class RoomWorkerStore(CacheInvalidationWorkerStore):
|
||||||
UNION SELECT room_id from appservice_room_list
|
UNION SELECT room_id from appservice_room_list
|
||||||
"""
|
"""
|
||||||
|
|
||||||
sql = """
|
sql = f"""
|
||||||
SELECT
|
SELECT
|
||||||
COUNT(*)
|
COUNT(*)
|
||||||
FROM (
|
FROM (
|
||||||
%(published_sql)s
|
{published_sql}
|
||||||
) published
|
) published
|
||||||
INNER JOIN room_stats_state USING (room_id)
|
INNER JOIN room_stats_state USING (room_id)
|
||||||
INNER JOIN room_stats_current USING (room_id)
|
INNER JOIN room_stats_current USING (room_id)
|
||||||
WHERE
|
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'
|
OR history_visibility = 'world_readable'
|
||||||
)
|
)
|
||||||
AND joined_members > 0
|
AND joined_members > 0
|
||||||
""" % {
|
"""
|
||||||
"published_sql": published_sql,
|
|
||||||
"knock_join_rule": JoinRules.KNOCK,
|
|
||||||
}
|
|
||||||
|
|
||||||
txn.execute(sql, query_args)
|
txn.execute(sql, query_args)
|
||||||
return cast(Tuple[int], txn.fetchone())[0]
|
return cast(Tuple[int], txn.fetchone())[0]
|
||||||
|
@ -369,29 +368,29 @@ class RoomWorkerStore(CacheInvalidationWorkerStore):
|
||||||
if where_clauses:
|
if where_clauses:
|
||||||
where_clause = " AND " + " AND ".join(where_clauses)
|
where_clause = " AND " + " AND ".join(where_clauses)
|
||||||
|
|
||||||
sql = """
|
dir = "DESC" if forwards else "ASC"
|
||||||
|
sql = f"""
|
||||||
SELECT
|
SELECT
|
||||||
room_id, name, topic, canonical_alias, joined_members,
|
room_id, name, topic, canonical_alias, joined_members,
|
||||||
avatar, history_visibility, guest_access, join_rules
|
avatar, history_visibility, guest_access, join_rules
|
||||||
FROM (
|
FROM (
|
||||||
%(published_sql)s
|
{published_sql}
|
||||||
) published
|
) published
|
||||||
INNER JOIN room_stats_state USING (room_id)
|
INNER JOIN room_stats_state USING (room_id)
|
||||||
INNER JOIN room_stats_current USING (room_id)
|
INNER JOIN room_stats_current USING (room_id)
|
||||||
WHERE
|
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'
|
OR history_visibility = 'world_readable'
|
||||||
)
|
)
|
||||||
AND joined_members > 0
|
AND joined_members > 0
|
||||||
%(where_clause)s
|
{where_clause}
|
||||||
ORDER BY joined_members %(dir)s, room_id %(dir)s
|
ORDER BY
|
||||||
""" % {
|
joined_members {dir},
|
||||||
"published_sql": published_sql,
|
room_id {dir}
|
||||||
"where_clause": where_clause,
|
"""
|
||||||
"dir": "DESC" if forwards else "ASC",
|
|
||||||
"knock_join_rule": JoinRules.KNOCK,
|
|
||||||
}
|
|
||||||
|
|
||||||
if limit is not None:
|
if limit is not None:
|
||||||
query_args.append(limit)
|
query_args.append(limit)
|
||||||
|
|
Loading…
Reference in New Issue