summary refs log tree commit diff
path: root/synapse/handlers/room_member.py
diff options
context:
space:
mode:
authorDavid Baker <dave@matrix.org>2017-10-03 13:53:09 +0100
committerDavid Baker <dave@matrix.org>2017-10-03 13:56:43 +0100
commit84716d267c6d93cfe759e8da336efb3136dc1560 (patch)
treed9f4653e58a51066121d4e965c185dfe3cba1ae4 /synapse/handlers/room_member.py
parentMerge pull request #2491 from matrix-org/rav/port_db_fixes (diff)
downloadsynapse-84716d267c6d93cfe759e8da336efb3136dc1560.tar.xz
Allow spam checker to reject invites too
Diffstat (limited to '')
-rw-r--r--synapse/handlers/room_member.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/synapse/handlers/room_member.py b/synapse/handlers/room_member.py
index 9a498c2d3e..61b0140e69 100644
--- a/synapse/handlers/room_member.py
+++ b/synapse/handlers/room_member.py
@@ -48,6 +48,7 @@ class RoomMemberHandler(BaseHandler):
         self.member_linearizer = Linearizer(name="member")
 
         self.clock = hs.get_clock()
+        self.spam_checker = hs.get_spam_checker()
 
         self.distributor = hs.get_distributor()
         self.distributor.declare("user_joined_room")
@@ -210,12 +211,19 @@ class RoomMemberHandler(BaseHandler):
             if is_blocked:
                 raise SynapseError(403, "This room has been blocked on this server")
 
-        if (effective_membership_state == "invite" and
-                self.hs.config.block_non_admin_invites):
-            is_requester_admin = yield self.auth.is_server_admin(
-                requester.user,
-            )
-            if not is_requester_admin:
+        if effective_membership_state == "invite":
+            block_invite = False
+            if self.hs.config.block_non_admin_invites:
+                is_requester_admin = yield self.auth.is_server_admin(
+                    requester.user,
+                )
+                if not is_requester_admin:
+                    block_invite = True
+
+            if not self.spam_checker.user_may_invite(requester.user):
+                block_invite = True
+
+            if block_invite:
                 raise SynapseError(
                     403, "Invites have been disabled on this server",
                 )