Do not apply ratelimiting on joins to appservices (#8139)

Add new method ratelimiter.can_requester_do_action and ensure that appservices are exempt from being ratelimited.

Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
Co-authored-by: Erik Johnston <erik@matrix.org>
This commit is contained in:
Will Hunt 2020-08-21 15:07:56 +01:00 committed by Brendan Abolivier
parent 3234d5c305
commit 2df82ae451
No known key found for this signature in database
GPG key ID: 1E015C145F1916CD
4 changed files with 119 additions and 6 deletions

View file

@ -459,9 +459,10 @@ class RoomMemberHandler(object):
if is_host_in_room:
time_now_s = self.clock.time()
allowed, time_allowed = self._join_rate_limiter_local.can_do_action(
requester.user.to_string(),
)
(
allowed,
time_allowed,
) = self._join_rate_limiter_local.can_requester_do_action(requester,)
if not allowed:
raise LimitExceededError(
@ -470,9 +471,10 @@ class RoomMemberHandler(object):
else:
time_now_s = self.clock.time()
allowed, time_allowed = self._join_rate_limiter_remote.can_do_action(
requester.user.to_string(),
)
(
allowed,
time_allowed,
) = self._join_rate_limiter_remote.can_requester_do_action(requester,)
if not allowed:
raise LimitExceededError(