summary refs log tree commit diff
path: root/synapse/handlers/directory.py
diff options
context:
space:
mode:
authorAndrew Morgan <1342360+anoadragon453@users.noreply.github.com>2023-04-17 18:57:40 -0600
committerGitHub <noreply@github.com>2023-04-18 00:57:40 +0000
commitaec639e3e33f5ca2f3456c715d28fd7a63c63c8a (patch)
treec5c765186899cd4527e2e57d9c084c8c0691d0fc /synapse/handlers/directory.py
parentAdd a note to the config documentation that the 'delete_stale_devices_after' ... (diff)
downloadsynapse-aec639e3e33f5ca2f3456c715d28fd7a63c63c8a.tar.xz
Move Spam Checker callbacks to a dedicated file (#15453)
Diffstat (limited to 'synapse/handlers/directory.py')
-rw-r--r--synapse/handlers/directory.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/synapse/handlers/directory.py b/synapse/handlers/directory.py
index 1fb23cc9bf..5e8316e2e5 100644
--- a/synapse/handlers/directory.py
+++ b/synapse/handlers/directory.py
@@ -60,7 +60,7 @@ class DirectoryHandler:
             "directory", self.on_directory_query
         )
 
-        self.spam_checker = hs.get_spam_checker()
+        self._spam_checker_module_callbacks = hs.get_module_api_callbacks().spam_checker
 
     async def _create_association(
         self,
@@ -145,10 +145,12 @@ class DirectoryHandler:
                         403, "You must be in the room to create an alias for it"
                     )
 
-            spam_check = await self.spam_checker.user_may_create_room_alias(
-                user_id, room_alias
+            spam_check = (
+                await self._spam_checker_module_callbacks.user_may_create_room_alias(
+                    user_id, room_alias
+                )
             )
-            if spam_check != self.spam_checker.NOT_SPAM:
+            if spam_check != self._spam_checker_module_callbacks.NOT_SPAM:
                 raise AuthError(
                     403,
                     "This user is not permitted to create this alias",
@@ -444,7 +446,9 @@ class DirectoryHandler:
         """
         user_id = requester.user.to_string()
 
-        spam_check = await self.spam_checker.user_may_publish_room(user_id, room_id)
+        spam_check = await self._spam_checker_module_callbacks.user_may_publish_room(
+            user_id, room_id
+        )
         if spam_check != NOT_SPAM:
             raise AuthError(
                 403,