Skip to content

Instantly share code, notes, and snippets.

@richvdh
Created October 22, 2019 11:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richvdh/092934e994a2443bd184a01357c98677 to your computer and use it in GitHub Desktop.
Save richvdh/092934e994a2443bd184a01357c98677 to your computer and use it in GitHub Desktop.
try:
is_auth_blocking = False
if self._config.mau_limit_alerting:
try:
# Normally should always pass in user_id to check_auth_blocking
# if you have it, but in this case are checking what would happen
# to other users if they were to arrive.
yield self._auth.check_auth_blocking()
except ResourceLimitError as e:
is_auth_blocking = True
event_body = e.msg
event_limit_type = e.limit_type
if currently_blocked and not is_auth_blocking:
# Room is notifying of a block, when it ought not to be.
yield self._remove_limit_block_notification(user_id, ref_events)
elif not currently_blocked and is_auth_blocking:
# Room is not notifying of a block, when it ought to be.
yield self._apply_limit_block_notification(
user_id, event_body, event_limit_type
)
except SynapseError as e:
logger.error("Error sending resource limits server notice: %s", e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment