diff options
author | Daniel Wagner-Hall <dawagner@gmail.com> | 2016-03-03 17:02:48 +0000 |
---|---|---|
committer | Daniel Wagner-Hall <dawagner@gmail.com> | 2016-03-03 17:02:48 +0000 |
commit | 0b3083c75b0eb256df8dc1f5f71db134c3428035 (patch) | |
tree | ee0061a97caacbbbcd43aebcc4bc295facc05fbd /synapse/handlers/_base.py | |
parent | Merge pull request #620 from matrix-org/erikj/jenkins (diff) | |
parent | Pass whole requester to ratelimiting (diff) | |
download | synapse-0b3083c75b0eb256df8dc1f5f71db134c3428035.tar.xz |
Merge pull request #621 from matrix-org/daniel/ratelimiting
Pass whole requester to ratelimiting
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 bdade98bf7..2333fc0c09 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, ) @@ -263,11 +263,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) |