diff options
author | Erik Johnston <erikj@jki.re> | 2019-01-29 23:07:00 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-29 23:07:00 +0000 |
commit | e12313ba2571c8e416136b9eb1e6620504d9a113 (patch) | |
tree | b62b1658804c8f76cde6f5a9d24e7aff3af56438 /synapse/event_auth.py | |
parent | Merge pull request #4514 from matrix-org/erikj/remove_event_id (diff) | |
parent | Merge branch 'develop' of github.com:matrix-org/synapse into erikj/redactions... (diff) | |
download | synapse-e12313ba2571c8e416136b9eb1e6620504d9a113.tar.xz |
Merge pull request #4499 from matrix-org/erikj/redactions_eiah
Implement rechecking of redactions for room versions v3
Diffstat (limited to 'synapse/event_auth.py')
-rw-r--r-- | synapse/event_auth.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/synapse/event_auth.py b/synapse/event_auth.py index e8da5310ed..8f9e330da5 100644 --- a/synapse/event_auth.py +++ b/synapse/event_auth.py @@ -26,6 +26,7 @@ from synapse.api.constants import ( EventTypes, JoinRules, Membership, + RoomVersions, ) from synapse.api.errors import AuthError, EventSizeError, SynapseError from synapse.types import UserID, get_domain_from_id @@ -177,7 +178,7 @@ def check(room_version, event, auth_events, do_sig_check=True, do_size_check=Tru _check_power_levels(event, auth_events) if event.type == EventTypes.Redaction: - check_redaction(event, auth_events) + check_redaction(room_version, event, auth_events) logger.debug("Allowing! %s", event) @@ -431,7 +432,7 @@ def _can_send_event(event, auth_events): return True -def check_redaction(event, auth_events): +def check_redaction(room_version, event, auth_events): """Check whether the event sender is allowed to redact the target event. Returns: @@ -451,10 +452,16 @@ def check_redaction(event, auth_events): if user_level >= redact_level: return False - redacter_domain = get_domain_from_id(event.event_id) - redactee_domain = get_domain_from_id(event.redacts) - if redacter_domain == redactee_domain: + if room_version in (RoomVersions.V1, RoomVersions.V2,): + redacter_domain = get_domain_from_id(event.event_id) + redactee_domain = get_domain_from_id(event.redacts) + if redacter_domain == redactee_domain: + return True + elif room_version == RoomVersions.V3: + event.internal_metadata.recheck_redaction = True return True + else: + raise RuntimeError("Unrecognized room version %r" % (room_version,)) raise AuthError( 403, |