Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configurable room list publishing rules #4647

Merged
merged 9 commits into from Feb 15, 2019

Hoist up checks to reduce overall work

  • Loading branch information...
erikjohnston committed Feb 15, 2019
commit 02c729d6b0f6b8f41455737cde0b8aeb39782a7e
@@ -177,24 +177,22 @@ def matches(self, user_id, room_id, aliases):
if not self._user_id_regex.match(user_id):
return False

# If we are not given any aliases then this rule only matches if the
# alias glob matches all aliases
matched = 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
if not self._room_id_regex.match(room_id):
return False

if not matched:
return False
# We only have alias checks left, so we can short circuit if the alias
# rule matches everything.
if self._alias_matches_all:
return True

if not self._room_id_regex.match(room_id):
# If we are not given any aliases then this rule only matches if the
# alias glob matches all aliases, which we checked above.
if not aliases:
return False

return True
# Otherwise, we just need one alias to match
for alias in aliases:
if self._alias_regex.match(alias):
return True

return False
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.