Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Land basic reaction and edit support. #5209

Merged
merged 24 commits into from
May 20, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
ae69a6a
Merge branch 'erikj/async_serialize_event' into erikj/reactions_rebase
erikjohnston May 14, 2019
495e859
Merge branch 'erikj/fix_config_ratelimiting' into erikj/test
erikjohnston May 14, 2019
a9fc71c
Merge branch 'erikj/refactor_pagination_bounds' into erikj/reactions_…
erikjohnston May 15, 2019
efe3c79
Add simple send_relation API and track in DB
erikjohnston May 14, 2019
b50641e
Add simple pagination API
erikjohnston May 14, 2019
5fb72e6
Newsfile
erikjohnston May 14, 2019
e6459c2
Actually implement idempotency
erikjohnston May 15, 2019
5be34fc
Actually check for None rather falsey
erikjohnston May 15, 2019
f201a30
Merge pull request #5186 from matrix-org/erikj/simple_pagination
erikjohnston May 16, 2019
a060352
Add aggregations API
erikjohnston May 14, 2019
3345341
Add cache to relations
erikjohnston May 16, 2019
b5c62c6
Fix relations in worker mode
erikjohnston May 16, 2019
95f3fcd
Check that event is visible in new APIs
erikjohnston May 16, 2019
2c662dd
Indirect tuple conversion
erikjohnston May 16, 2019
7a7eba8
Move parsing of tokens out of storage layer
erikjohnston May 16, 2019
5c39d26
Merge pull request #5192 from matrix-org/erikj/relations_aggregations
erikjohnston May 16, 2019
d46aab3
Add basic editing support
erikjohnston May 14, 2019
5dbff34
Fixup bsaed on review comments
erikjohnston May 17, 2019
d4ca533
Make tests use different user for each reaction it sends
erikjohnston May 17, 2019
210cb6d
Merge pull request #5195 from matrix-org/erikj/edits
erikjohnston May 20, 2019
935af0d
Correctly update aggregation counts after redaction
erikjohnston May 20, 2019
2ac9c96
Fixup comments
erikjohnston May 20, 2019
9ad246e
Merge pull request #5207 from matrix-org/erikj/reactions_redactions
erikjohnston May 20, 2019
0667105
Newsfile
erikjohnston May 20, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Correctly update aggregation counts after redaction
  • Loading branch information
erikjohnston committed May 20, 2019
commit 935af0da380f39ba284b78054270331bdbad7712
3 changes: 3 additions & 0 deletions synapse/storage/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -1325,6 +1325,9 @@ def _update_metadata_tables_txn(
txn, event.room_id, event.redacts
)

# Remove from relations table.
self._handle_redaction(txn, event.redacts)

# Update the event_forward_extremities, event_backward_extremities and
# event_edges tables.
self._handle_mult_prev_events(
Expand Down
17 changes: 17 additions & 0 deletions synapse/storage/relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,3 +415,20 @@ def _handle_event_relations(self, txn, event):

if rel_type == RelationTypes.REPLACES:
txn.call_after(self.get_applicable_edit.invalidate, (parent_id,))

def _handle_redaction(self, txn, redacted_event_id):
"""Handles receiving a redaction and checking whether we need to remove
any redacted relations from the database.

Args:
txn
redacted_event_id (str): The event that was redacted.
"""

self._simple_delete_txn(
txn,
table="event_relations",
keyvalues={
"event_id": redacted_event_id,
}
)
37 changes: 37 additions & 0 deletions tests/rest/client/v2_alpha/test_relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,43 @@ def test_aggregation(self):
},
)

def test_aggregation_redactions(self):
"""Test that annotations get correctly aggregated after a redactions.
"""

channel = self._send_relation(RelationTypes.ANNOTATION, "m.reaction", "a")
self.assertEquals(200, channel.code, channel.json_body)
to_redact_event_id = channel.json_body["event_id"]

channel = self._send_relation(
RelationTypes.ANNOTATION, "m.reaction", "a", access_token=self.user2_token
)
self.assertEquals(200, channel.code, channel.json_body)

# Now lets redact the 'a' reaction
request, channel = self.make_request(
"POST",
"/_matrix/client/r0/rooms/%s/redact/%s" % (self.room, to_redact_event_id),
access_token=self.user_token,
content={},
)
self.render(request)
self.assertEquals(200, channel.code, channel.json_body)

request, channel = self.make_request(
"GET",
"/_matrix/client/unstable/rooms/%s/aggregations/%s"
% (self.room, self.parent_id),
access_token=self.user_token,
)
self.render(request)
self.assertEquals(200, channel.code, channel.json_body)

self.assertEquals(
channel.json_body,
{"chunk": [{"type": "m.reaction", "key": "a", "count": 1}]},
)

def test_aggregation_must_be_annotation(self):
"""Test that aggregations must be annotations.
"""
Expand Down