Ensure that event.redacts is the proper type before handling it (#8457)

This fixes a bug when backfilling invalid events.
This commit is contained in:
Patrick Cloke 2020-10-05 10:24:17 -04:00 committed by GitHub
parent 0991a2da93
commit da11cc22be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 0 deletions

1
changelog.d/8457.bugfix Normal file
View file

@ -0,0 +1 @@
Fix a bug where backfilling a room with an event that was missing the `redacts` field would break.

View file

@ -446,6 +446,8 @@ def check_redaction(
if room_version_obj.event_format == EventFormatVersions.V1:
redacter_domain = get_domain_from_id(event.event_id)
if not isinstance(event.redacts, str):
return False
redactee_domain = get_domain_from_id(event.redacts)
if redacter_domain == redactee_domain:
return True