summary refs log tree commit diff
diff options
context:
space:
mode:
authorRichard van der Hoff <1389908+richvdh@users.noreply.github.com>2021-06-29 11:08:06 +0100
committerGitHub <noreply@github.com>2021-06-29 11:08:06 +0100
commita0ed0f363eb84f273b2cc706fcc5542d77a94463 (patch)
tree1725f7d2eb50e7e94cb85c4a2ba523bbaaec526e
parentMerge branch 'master' into develop (diff)
downloadsynapse-a0ed0f363eb84f273b2cc706fcc5542d77a94463.tar.xz
Soft-fail spammy events received over federation (#10263)
-rw-r--r--changelog.d/10263.feature1
-rw-r--r--synapse/federation/federation_base.py12
2 files changed, 7 insertions, 6 deletions
diff --git a/changelog.d/10263.feature b/changelog.d/10263.feature
new file mode 100644
index 0000000000..7b1d2fe60f
--- /dev/null
+++ b/changelog.d/10263.feature
@@ -0,0 +1 @@
+Mark events received over federation which fail a spam check as "soft-failed".
diff --git a/synapse/federation/federation_base.py b/synapse/federation/federation_base.py
index c066617b92..2bfe6a3d37 100644
--- a/synapse/federation/federation_base.py
+++ b/synapse/federation/federation_base.py
@@ -89,12 +89,12 @@ class FederationBase:
         result = await self.spam_checker.check_event_for_spam(pdu)
 
         if result:
-            logger.warning(
-                "Event contains spam, redacting %s: %s",
-                pdu.event_id,
-                pdu.get_pdu_json(),
-            )
-            return prune_event(pdu)
+            logger.warning("Event contains spam, soft-failing %s", pdu.event_id)
+            # we redact (to save disk space) as well as soft-failing (to stop
+            # using the event in prev_events).
+            redacted_event = prune_event(pdu)
+            redacted_event.internal_metadata.soft_failed = True
+            return redacted_event
 
         return pdu