Skip to content

Commit

Permalink
Add bypass_for_users config
Browse files Browse the repository at this point in the history
  • Loading branch information
MatMaul committed Jun 13, 2024
1 parent e8c00a0 commit 558b08e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions room_access_rules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class AccessRules:
@attr.s(frozen=True, auto_attribs=True)
class RoomAccessRulesConfig:
id_server: str
bypass_for_users: List[str] = []
domains_forbidden_when_restricted: List[str] = []
fix_admins_for_dm_power_levels: bool = False
add_live_location_power_levels: bool = False
Expand Down Expand Up @@ -306,6 +307,9 @@ async def on_create_room(
access_rule = None
join_rule = None

if requester.user.to_string() in self.config.bypass_for_users:
return True

# If there's a rules event in the initial state, check if it complies with the
# spec for im.vector.room.access_rules and deny the request if not.
for event in config.get("initial_state", []):
Expand Down Expand Up @@ -504,6 +508,9 @@ async def check_event_allowed(
allowed, False if it should be rejected. The second entry is always
None because this module doesn't replace event contents.
"""
if event.sender in self.config.bypass_for_users:
return True, None

# We check the rules when altering the state of the room, so only go further if
# the event is a state event.
if event.is_state():
Expand Down

0 comments on commit 558b08e

Please sign in to comment.