@@ -461,6 +461,28 @@ def test_aggregation_get_event(self):
461
461
},
462
462
)
463
463
464
+ def test_aggregation_get_event_for_annotation (self ):
465
+ """Test that annotations do not get bundled relations included
466
+ when directly requested.
467
+ """
468
+ channel = self ._send_relation (RelationTypes .ANNOTATION , "m.reaction" , "a" )
469
+ self .assertEquals (200 , channel .code , channel .json_body )
470
+ annotation_id = channel .json_body ["event_id" ]
471
+
472
+ # Annotate the annotation.
473
+ channel = self ._send_relation (
474
+ RelationTypes .ANNOTATION , "m.reaction" , "a" , parent_id = annotation_id
475
+ )
476
+ self .assertEquals (200 , channel .code , channel .json_body )
477
+
478
+ channel = self .make_request (
479
+ "GET" ,
480
+ f"/rooms/{ self .room } /event/{ annotation_id } " ,
481
+ access_token = self .user_token ,
482
+ )
483
+ self .assertEquals (200 , channel .code , channel .json_body )
484
+ self .assertIsNone (channel .json_body ["unsigned" ].get ("m.relations" ))
485
+
464
486
def test_aggregation_get_event_for_thread (self ):
465
487
"""Test that threads get bundled relations included when directly requested."""
466
488
channel = self ._send_relation (RelationTypes .THREAD , "m.room.test" )
@@ -653,6 +675,56 @@ def test_edit_reply(self):
653
675
{"event_id" : edit_event_id , "sender" : self .user_id }, m_replace_dict
654
676
)
655
677
678
+ def test_edit_edit (self ):
679
+ """Test that an edit cannot be edited."""
680
+ new_body = {"msgtype" : "m.text" , "body" : "Initial edit" }
681
+ channel = self ._send_relation (
682
+ RelationTypes .REPLACE ,
683
+ "m.room.message" ,
684
+ content = {
685
+ "msgtype" : "m.text" ,
686
+ "body" : "Wibble" ,
687
+ "m.new_content" : new_body ,
688
+ },
689
+ )
690
+ self .assertEquals (200 , channel .code , channel .json_body )
691
+ edit_event_id = channel .json_body ["event_id" ]
692
+
693
+ # Edit the edit event.
694
+ channel = self ._send_relation (
695
+ RelationTypes .REPLACE ,
696
+ "m.room.message" ,
697
+ content = {
698
+ "msgtype" : "m.text" ,
699
+ "body" : "foo" ,
700
+ "m.new_content" : {"msgtype" : "m.text" , "body" : "Ignored edit" },
701
+ },
702
+ parent_id = edit_event_id ,
703
+ )
704
+ self .assertEquals (200 , channel .code , channel .json_body )
705
+
706
+ # Request the original event.
707
+ channel = self .make_request (
708
+ "GET" ,
709
+ "/rooms/%s/event/%s" % (self .room , self .parent_id ),
710
+ access_token = self .user_token ,
711
+ )
712
+ self .assertEquals (200 , channel .code , channel .json_body )
713
+ # The edit to the edit should be ignored.
714
+ self .assertEquals (channel .json_body ["content" ], new_body )
715
+
716
+ # The relations information should not include the edit to the edit.
717
+ relations_dict = channel .json_body ["unsigned" ].get ("m.relations" )
718
+ self .assertIn (RelationTypes .REPLACE , relations_dict )
719
+
720
+ m_replace_dict = relations_dict [RelationTypes .REPLACE ]
721
+ for key in ["event_id" , "sender" , "origin_server_ts" ]:
722
+ self .assertIn (key , m_replace_dict )
723
+
724
+ self .assert_dict (
725
+ {"event_id" : edit_event_id , "sender" : self .user_id }, m_replace_dict
726
+ )
727
+
656
728
def test_relations_redaction_redacts_edits (self ):
657
729
"""Test that edits of an event are redacted when the original event
658
730
is redacted.
0 commit comments