summary refs log tree commit diff
path: root/synapse/rest
diff options
context:
space:
mode:
authorDavid Teller <D.O.Teller@gmail.com>2022-06-13 20:16:16 +0200
committerGitHub <noreply@github.com>2022-06-13 18:16:16 +0000
commita164a46038b0e51142781619db0e6dec8e0c2aaa (patch)
tree5e7016296e6d10953c5f594461262b0fac46bb12 /synapse/rest
parentReplace noop background updates with DELETE. (#12954) (diff)
downloadsynapse-a164a46038b0e51142781619db0e6dec8e0c2aaa.tar.xz
Uniformize spam-checker API, part 4: port other spam-checker callbacks to return `Union[Allow, Codes]`. (#12857)
Co-authored-by: Brendan Abolivier <babolivier@matrix.org>
Diffstat (limited to 'synapse/rest')
-rw-r--r--synapse/rest/media/v1/media_storage.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/synapse/rest/media/v1/media_storage.py b/synapse/rest/media/v1/media_storage.py
index 604f18bf52..9137417342 100644
--- a/synapse/rest/media/v1/media_storage.py
+++ b/synapse/rest/media/v1/media_storage.py
@@ -36,6 +36,7 @@ from twisted.internet.defer import Deferred
 from twisted.internet.interfaces import IConsumer
 from twisted.protocols.basic import FileSender
 
+import synapse
 from synapse.api.errors import NotFoundError
 from synapse.logging.context import defer_to_thread, make_deferred_yieldable
 from synapse.util import Clock
@@ -145,15 +146,15 @@ class MediaStorage:
                     f.flush()
                     f.close()
 
-                    spam = await self.spam_checker.check_media_file_for_spam(
+                    spam_check = await self.spam_checker.check_media_file_for_spam(
                         ReadableFileWrapper(self.clock, fname), file_info
                     )
-                    if spam:
+                    if spam_check != synapse.module_api.NOT_SPAM:
                         logger.info("Blocking media due to spam checker")
                         # Note that we'll delete the stored media, due to the
                         # try/except below. The media also won't be stored in
                         # the DB.
-                        raise SpamMediaException()
+                        raise SpamMediaException(errcode=spam_check)
 
                     for provider in self.storage_providers:
                         await provider.store_file(path, file_info)