Add origin_server_ts and sender fields to m.replace (#5613)

Riot team would like some extra fields as part of m.replace, so here you go.

Fixes: #5598
pull/5641/head
Andrew Morgan 2019-07-05 17:20:02 +01:00 committed by GitHub
parent 80cc82a445
commit ad8b909ce9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 7 deletions

1
changelog.d/5613.feature Normal file
View File

@ -0,0 +1 @@
Add `sender` and `origin_server_ts` fields to `m.replace`.

View File

@ -392,7 +392,11 @@ class EventClientSerializer(object):
serialized_event["content"].pop("m.relates_to", None)
r = serialized_event["unsigned"].setdefault("m.relations", {})
r[RelationTypes.REPLACE] = {"event_id": edit.event_id}
r[RelationTypes.REPLACE] = {
"event_id": edit.event_id,
"origin_server_ts": edit.origin_server_ts,
"sender": edit.sender,
}
defer.returnValue(serialized_event)

View File

@ -466,9 +466,15 @@ class RelationsTestCase(unittest.HomeserverTestCase):
self.assertEquals(channel.json_body["content"], new_body)
self.assertEquals(
channel.json_body["unsigned"].get("m.relations"),
{RelationTypes.REPLACE: {"event_id": edit_event_id}},
relations_dict = channel.json_body["unsigned"].get("m.relations")
self.assertIn(RelationTypes.REPLACE, relations_dict)
m_replace_dict = relations_dict[RelationTypes.REPLACE]
for key in ["event_id", "sender", "origin_server_ts"]:
self.assertIn(key, m_replace_dict)
self.assert_dict(
{"event_id": edit_event_id, "sender": self.user_id}, m_replace_dict
)
def test_multi_edit(self):
@ -518,9 +524,15 @@ class RelationsTestCase(unittest.HomeserverTestCase):
self.assertEquals(channel.json_body["content"], new_body)
self.assertEquals(
channel.json_body["unsigned"].get("m.relations"),
{RelationTypes.REPLACE: {"event_id": edit_event_id}},
relations_dict = channel.json_body["unsigned"].get("m.relations")
self.assertIn(RelationTypes.REPLACE, relations_dict)
m_replace_dict = relations_dict[RelationTypes.REPLACE]
for key in ["event_id", "sender", "origin_server_ts"]:
self.assertIn(key, m_replace_dict)
self.assert_dict(
{"event_id": edit_event_id, "sender": self.user_id}, m_replace_dict
)
def _send_relation(