mirror of
https://github.com/element-hq/synapse.git
synced 2024-11-22 09:35:45 +03:00
Clarify and fix behaviour when there are multiple aliases
This commit is contained in:
parent
f61b2068e6
commit
cb12a37708
2 changed files with 23 additions and 5 deletions
|
@ -58,7 +58,11 @@ class RoomDirectoryConfig(Config):
|
||||||
# which rooms can be published in the public room list.
|
# which rooms can be published in the public room list.
|
||||||
#
|
#
|
||||||
# The format of this option is the same as that for
|
# The format of this option is the same as that for
|
||||||
# `alias_creation_rules`
|
# `alias_creation_rules`.
|
||||||
|
#
|
||||||
|
# If the room has one or more aliases associated with it, the rules are
|
||||||
|
# run against each alias. If there are no aliases then only rules with
|
||||||
|
# `alias: *` match.
|
||||||
room_list_publication_rules:
|
room_list_publication_rules:
|
||||||
- user_id: "*" # Matches against the user publishing the room
|
- user_id: "*" # Matches against the user publishing the room
|
||||||
alias: "*" # Matches against any current local or canonical
|
alias: "*" # Matches against any current local or canonical
|
||||||
|
@ -156,11 +160,19 @@ class _RoomDirectoryRule(object):
|
||||||
|
|
||||||
# If we are not given any aliases then this rule only matches if the
|
# If we are not given any aliases then this rule only matches if the
|
||||||
# alias glob matches all aliases
|
# alias glob matches all aliases
|
||||||
if not aliases and not self._alias_matches_all:
|
matched = False
|
||||||
return False
|
if not aliases:
|
||||||
|
if not self._alias_matches_all:
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
# Otherwise, we just need one alias to match
|
||||||
|
matched = False
|
||||||
|
for alias in aliases:
|
||||||
|
if self._alias_regex.match(alias):
|
||||||
|
matched = True
|
||||||
|
break
|
||||||
|
|
||||||
for alias in aliases:
|
if not matched:
|
||||||
if not self._alias_regex.match(alias):
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if not self._room_id_regex.match(room_id):
|
if not self._room_id_regex.match(room_id):
|
||||||
|
|
|
@ -138,3 +138,9 @@ class RoomDirectoryConfigTestCase(unittest.TestCase):
|
||||||
room_id="!test-deny",
|
room_id="!test-deny",
|
||||||
aliases=[],
|
aliases=[],
|
||||||
))
|
))
|
||||||
|
|
||||||
|
self.assertTrue(rd_config.is_publishing_room_allowed(
|
||||||
|
user_id="@test:example.com",
|
||||||
|
room_id="!test",
|
||||||
|
aliases=["#unofficial_st:example.com", "#blah:example.com"],
|
||||||
|
))
|
||||||
|
|
Loading…
Reference in a new issue