|
20 | 20 | from synapse.rest import admin |
21 | 21 | from synapse.rest.client import login, room, sync |
22 | 22 | from synapse.server import HomeServer |
| 23 | +from synapse.storage._base import db_to_json |
| 24 | +from synapse.storage.database import LoggingTransaction |
23 | 25 | from synapse.types import JsonDict |
24 | 26 | from synapse.util import Clock |
25 | 27 |
|
@@ -597,5 +599,20 @@ def test_content_redaction(self) -> None: |
597 | 599 | redact_event = timeline[-1] |
598 | 600 | self.assertEqual(redact_event["type"], EventTypes.Redaction) |
599 | 601 | # The redacts key should be in the content. |
600 | | - self.assertNotIn("redacts", redact_event) |
601 | 602 | self.assertEquals(redact_event["content"]["redacts"], event_id) |
| 603 | + |
| 604 | + # It should also be copied as the top-level redacts field for backwards |
| 605 | + # compatibility. |
| 606 | + self.assertEquals(redact_event["redacts"], event_id) |
| 607 | + |
| 608 | + # But it isn't actually part of the event. |
| 609 | + def get_event(txn: LoggingTransaction) -> JsonDict: |
| 610 | + return db_to_json( |
| 611 | + main_datastore._fetch_event_rows(txn, [event_id])[event_id].json |
| 612 | + ) |
| 613 | + |
| 614 | + main_datastore = self.hs.get_datastores().main |
| 615 | + event_json = self.get_success( |
| 616 | + main_datastore.db_pool.runInteraction("get_event", get_event) |
| 617 | + ) |
| 618 | + self.assertNotIn("redacts", event_json) |
0 commit comments