summary refs log tree commit diff
path: root/synapse/handlers/room_member.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2019-04-26 18:06:25 +0100
committerErik Johnston <erik@matrix.org>2019-04-26 18:06:25 +0100
commit28a81ed62fdf489001385514e666729d85deb4bc (patch)
tree9f983a6fd9f7fb5cc9f253e72be3081356238c11 /synapse/handlers/room_member.py
parentNewsfile (diff)
downloadsynapse-28a81ed62fdf489001385514e666729d85deb4bc.tar.xz
Ratelimit 3pid invites
We do ratelimit sending the 3PID invite events, but that happens after
spamming the identity server.
Diffstat (limited to 'synapse/handlers/room_member.py')
-rw-r--r--synapse/handlers/room_member.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/synapse/handlers/room_member.py b/synapse/handlers/room_member.py
index e432740832..53e0103b5b 100644
--- a/synapse/handlers/room_member.py
+++ b/synapse/handlers/room_member.py
@@ -33,6 +33,8 @@ from synapse.types import RoomID, UserID
 from synapse.util.async_helpers import Linearizer
 from synapse.util.distributor import user_joined_room, user_left_room
 
+from ._base import BaseHandler
+
 logger = logging.getLogger(__name__)
 
 id_server_scheme = "https://"
@@ -71,6 +73,11 @@ class RoomMemberHandler(object):
         self.spam_checker = hs.get_spam_checker()
         self._server_notices_mxid = self.config.server_notices_mxid
 
+        # This is only used to get at ratelimit function, and
+        # maybe_kick_guest_users. It's fine there are multiple of these as
+        # it doesn't store state.
+        self.base_handler = BaseHandler(hs)
+
     @abc.abstractmethod
     def _remote_join(self, requester, remote_room_hosts, room_id, user, content):
         """Try and join a room that this server is not in
@@ -702,6 +709,9 @@ class RoomMemberHandler(object):
                     Codes.FORBIDDEN,
                 )
 
+        # Check whether we'll be ratelimited
+        yield self.base_handler.ratelimit(requester, update=False)
+
         invitee = yield self._lookup_3pid(
             id_server, medium, address
         )