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

Fixes to MSC3787 implementation #12858

Merged
merged 4 commits into from
May 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/12858.bugfix
Original file line number Diff line number Diff line change
@@ -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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MSC3787*

also, you're implying it's a bug and not an intentional feature :p

(it's technically a bug, but was deliberately omitted from the original PR)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no context; I seek only to make the tests on matrix-org/complement#367 pass.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changelog updated in 6aeee9a

2 changes: 1 addition & 1 deletion scripts-dev/complement.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ docker build -t matrixdotorg/synapse -f "docker/Dockerfile" .

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 [[ -n "$WORKERS" ]]; then
Expand Down
3 changes: 2 additions & 1 deletion synapse/handlers/room_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,8 @@ async def _is_remote_room_accessible(
# The API doesn't return the room version so assume that a
# join rule of knock is valid.
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
):
return True
Expand Down
35 changes: 17 additions & 18 deletions synapse/storage/databases/main/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,24 +233,23 @@ def _count_public_rooms_txn(txn: LoggingTransaction) -> int:
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]
Expand Down Expand Up @@ -369,29 +368,29 @@ async def get_largest_public_rooms(
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)
Expand Down