summary refs log tree commit diff
path: root/synapse/storage/events_worker.py
diff options
context:
space:
mode:
authorBrendan Abolivier <babolivier@matrix.org>2019-07-30 15:55:18 +0200
committerBrendan Abolivier <babolivier@matrix.org>2019-07-30 15:55:18 +0200
commit8ced9a2f58783ef9dd93e9313c24114f7924e771 (patch)
tree4f2bc5f86acf0e21f35f4e98ac5ae899d8481e56 /synapse/storage/events_worker.py
parentDo checks sooner (diff)
downloadsynapse-8ced9a2f58783ef9dd93e9313c24114f7924e771.tar.xz
Don't make the checks depend on recheck_redaction
Diffstat (limited to 'synapse/storage/events_worker.py')
-rw-r--r--synapse/storage/events_worker.py43
1 files changed, 23 insertions, 20 deletions
diff --git a/synapse/storage/events_worker.py b/synapse/storage/events_worker.py

index cbb2529d5e..b5604cbdef 100644 --- a/synapse/storage/events_worker.py +++ b/synapse/storage/events_worker.py
@@ -255,6 +255,29 @@ class EventsWorkerStore(SQLBaseStore): # didn't have the redacted event at the time, so we recheck on read # instead. if not allow_rejected and entry.event.type == EventTypes.Redaction: + orig_event_info = yield self._simple_select_one( + table="events", + keyvalues={"event_id": entry.event.redacts}, + retcols=["sender", "room_id", "type"], + allow_none=True, + ) + + if not orig_event_info: + # We don't have the event that is being redacted, so we + # assume that the event isn't authorized for now. (If we + # later receive the event, then we will always redact + # it anyway, since we have this redaction) + continue + + if orig_event_info["room_id"] != entry.event.room_id: + # Don't process redactions if the redacted event doesn't belong to the + # redaction's room. + continue + + if orig_event_info["type"] == EventTypes.Redaction: + # Don't process redactions of redactions. + continue + if entry.event.internal_metadata.need_to_check_redaction(): # XXX: we need to avoid calling get_event here. # @@ -277,26 +300,6 @@ class EventsWorkerStore(SQLBaseStore): # 2. have _get_event_from_row just call the first half of # that - orig_event_info = yield self._simple_select_one( - table="events", - keyvalues={"event_id": entry.event.redacts}, - retcols=["sender", "room_id", "type"], - allow_none=True, - ) - - if not orig_event_info: - # We don't have the event that is being redacted, so we - # assume that the event isn't authorized for now. (If we - # later receive the event, then we will always redact - # it anyway, since we have this redaction) - continue - - if orig_event_info["room_id"] != entry.event.room_id: - continue - - if orig_event_info["type"] == EventTypes.Redaction: - continue - expected_domain = get_domain_from_id(entry.event.sender) if ( get_domain_from_id(orig_event_info["sender"]) == expected_domain