#NEWLINE# @ defer . inlineCallbacks #NEWLINE# def test_redact( self ) : #NEWLINE# #INDENT# ( yield self . inject_room_member ( self . room1 , self . u_alice , Membership . JOIN ) ) #NEWLINE# start = ( yield self . store . get_room_events_max_id ( ) ) #NEWLINE# msg_event = ( yield self . inject_message ( self . room1 , self . u_alice , 't' ) ) #NEWLINE# end = ( yield self . store . get_room_events_max_id ( ) ) #NEWLINE# ( results , _ ) = ( yield self . store . get_room_events_stream ( self . u_alice . to_string ( ) , start , end ) ) #NEWLINE# self . assertEqual ( 1 , len ( results ) ) #NEWLINE# event = results [ 0 ] #NEWLINE# self . assertObjectHasAttributes ( { #NEWLINE# #INDENT# 'type' : EventTypes . Message , #NEWLINE# 'user_id' : self . u_alice . to_string ( ) , #NEWLINE# 'content' : { #NEWLINE# #INDENT# 'body' : 't' , #NEWLINE# 'msgtype' : 'message' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , event ) #NEWLINE# self . assertFalse ( ( 'redacted_because' in start . unsigned ) ) #NEWLINE# reason = 'Because I said so' #NEWLINE# ( yield self . inject_redaction ( self . room1 , msg_event . event_id , self . u_alice , reason ) ) #NEWLINE# ( results , _ ) = ( yield self . store . get_room_events_stream ( self . u_alice . to_string ( ) , start , end ) ) #NEWLINE# self . assertEqual ( 1 , len ( results ) ) #NEWLINE# event = results [ 0 ] #NEWLINE# self . assertEqual ( msg_event . event_id , event . event_id ) #NEWLINE# self . assertTrue ( ( 'redacted_because' in event . unsigned ) ) #NEWLINE# self . assertObjectHasAttributes ( { #NEWLINE# #INDENT# 'type' : EventTypes . Message , #NEWLINE# 'user_id' : self . u_alice . to_string ( ) , #NEWLINE# 'content' : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , event ) #NEWLINE# self . assertObjectHasAttributes ( { #NEWLINE# #INDENT# 'type' : EventTypes . Redaction , #NEWLINE# 'user_id' : self . u_alice . to_string ( ) , #NEWLINE# 'content' : { #NEWLINE# #INDENT# 'reason' : reason , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , event . unsigned [ 'redacted_because' ] )