Soft-fail spammy events received over federation (#10263)

This commit is contained in:
Richard van der Hoff 2021-06-29 11:08:06 +01:00 committed by GitHub
parent 3d370efc6d
commit a0ed0f363e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 6 deletions

View File

@ -0,0 +1 @@
Mark events received over federation which fail a spam check as "soft-failed".

View File

@ -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