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) result = await self.spam_checker.check_event_for_spam(pdu)
if result: if result:
logger.warning( logger.warning("Event contains spam, soft-failing %s", pdu.event_id)
"Event contains spam, redacting %s: %s", # we redact (to save disk space) as well as soft-failing (to stop
pdu.event_id, # using the event in prev_events).
pdu.get_pdu_json(), redacted_event = prune_event(pdu)
) redacted_event.internal_metadata.soft_failed = True
return prune_event(pdu) return redacted_event
return pdu return pdu