diff options
author | Richard van der Hoff <richard@matrix.org> | 2016-03-03 19:05:54 +0000 |
---|---|---|
committer | Richard van der Hoff <richard@matrix.org> | 2016-03-03 19:05:54 +0000 |
commit | a85179aff3bf2bc1b132e9918cd8222a61a8bcc2 (patch) | |
tree | aac1ff9e5bdca7ddc0fdc9d2cae5a5dcf13e8733 /synapse/handlers/_base.py | |
parent | Empty commit (diff) | |
parent | Merge pull request #621 from matrix-org/daniel/ratelimiting (diff) | |
download | synapse-a85179aff3bf2bc1b132e9918cd8222a61a8bcc2.tar.xz |
Merge remote-tracking branch 'origin/develop' into rav/SYN-642
Diffstat (limited to 'synapse/handlers/_base.py')
-rw-r--r-- | synapse/handlers/_base.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/synapse/handlers/_base.py b/synapse/handlers/_base.py index a6f890e0b6..c6a74b0e3d 100644 --- a/synapse/handlers/_base.py +++ b/synapse/handlers/_base.py @@ -160,10 +160,10 @@ class BaseHandler(object): ) defer.returnValue(res.get(user_id, [])) - def ratelimit(self, user_id): + def ratelimit(self, requester): time_now = self.clock.time() allowed, time_allowed = self.ratelimiter.send_message( - user_id, time_now, + requester.user.to_string(), time_now, msg_rate_hz=self.hs.config.rc_messages_per_second, burst_count=self.hs.config.rc_message_burst_count, ) @@ -282,11 +282,18 @@ class BaseHandler(object): return False @defer.inlineCallbacks - def handle_new_client_event(self, event, context, ratelimit=True, extra_users=[]): + def handle_new_client_event( + self, + requester, + event, + context, + ratelimit=True, + extra_users=[] + ): # We now need to go and hit out to wherever we need to hit out to. if ratelimit: - self.ratelimit(event.sender) + self.ratelimit(requester) self.auth.check(event, auth_events=context.current_state) |