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

Commit

Permalink
Stop returning aliases as part of the room list. (#6970)
Browse files Browse the repository at this point in the history
* commit 'fcf459948':
  Stop returning aliases as part of the room list. (#6970)
  Publishing/removing from the directory requires a power level greater than canonical aliases.
  • Loading branch information
anoadragon453 committed Mar 24, 2020
2 parents 35d74a2 + fcf4599 commit 794a3d1
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 14 deletions.
1 change: 1 addition & 0 deletions changelog.d/6965.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Publishing/removing a room from the room directory now requires the user to have a power level capable of modifying the canonical alias, instead of the room aliases.
1 change: 1 addition & 0 deletions changelog.d/6970.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The room list endpoint no longer returns a list of aliases.
10 changes: 5 additions & 5 deletions synapse/api/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,13 +543,13 @@ def compute_auth_events(
return defer.succeed(auth_ids)

@defer.inlineCallbacks
def check_can_change_room_list(self, room_id, user):
def check_can_change_room_list(self, room_id: str, user: UserID):
"""Check if the user is allowed to edit the room's entry in the
published room list.
Args:
room_id (str)
user (UserID)
room_id
user
"""

is_admin = yield self.is_server_admin(user)
Expand All @@ -561,7 +561,7 @@ def check_can_change_room_list(self, room_id, user):

# We currently require the user is a "moderator" in the room. We do this
# by checking if they would (theoretically) be able to change the
# m.room.aliases events
# m.room.canonical_alias events
power_level_event = yield self.state.get_current_state(
room_id, EventTypes.PowerLevels, ""
)
Expand All @@ -571,7 +571,7 @@ def check_can_change_room_list(self, room_id, user):
auth_events[(EventTypes.PowerLevels, "")] = power_level_event

send_level = event_auth.get_send_level(
EventTypes.Aliases, "", power_level_event
EventTypes.CanonicalAlias, "", power_level_event
)
user_level = event_auth.get_user_power_level(user_id, auth_events)

Expand Down
9 changes: 0 additions & 9 deletions synapse/handlers/room_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,6 @@ def build_room_entry(room):
direction_is_forward=False,
).to_token()

for room in results:
# populate search result entries with additional fields, namely
# 'aliases'
room_id = room["room_id"]

aliases = yield self.store.get_aliases_for_room(room_id)
if aliases:
room["aliases"] = aliases

response["chunk"] = results

response["total_room_count_estimate"] = yield self.store.count_public_rooms(
Expand Down

0 comments on commit 794a3d1

Please sign in to comment.