Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Matrix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Operate
Environments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Matrix
Commits
02c729d6
Commit
02c729d6
authored
6 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Hoist up checks to reduce overall work
parent
02c46acc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
Loading
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/config/room_directory.py
+15
-17
15 additions, 17 deletions
synapse/config/room_directory.py
with
15 additions
and
17 deletions
synapse/config/room_directory.py
+
15
−
17
View file @
02c729d6
...
...
@@ -177,24 +177,22 @@ class _RoomDirectoryRule(object):
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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment