@@ -1112,23 +1112,21 @@ export class MatrixEvent extends TypedEventEmitter<EmittedEvents, MatrixEventHan
1112
1112
}
1113
1113
this . event . unsigned . redacted_because = redactionEvent . event as IEvent ;
1114
1114
1115
- let key ;
1116
- for ( key in this . event ) {
1117
- if ( ! this . event . hasOwnProperty ( key ) ) {
1118
- continue ;
1119
- }
1120
- if ( ! REDACT_KEEP_KEYS . has ( key ) ) {
1115
+ for ( const key in this . event ) {
1116
+ if ( this . event . hasOwnProperty ( key ) && ! REDACT_KEEP_KEYS . has ( key ) ) {
1121
1117
delete this . event [ key ] ;
1122
1118
}
1123
1119
}
1124
1120
1121
+ // If the event is encrypted prune the decrypted bits
1122
+ if ( this . isEncrypted ( ) ) {
1123
+ this . clearEvent = null ;
1124
+ }
1125
+
1125
1126
const keeps = REDACT_KEEP_CONTENT_MAP [ this . getType ( ) ] || { } ;
1126
1127
const content = this . getContent ( ) ;
1127
- for ( key in content ) {
1128
- if ( ! content . hasOwnProperty ( key ) ) {
1129
- continue ;
1130
- }
1131
- if ( ! keeps [ key ] ) {
1128
+ for ( const key in content ) {
1129
+ if ( content . hasOwnProperty ( key ) && ! keeps [ key ] ) {
1132
1130
delete content [ key ] ;
1133
1131
}
1134
1132
}
@@ -1589,7 +1587,7 @@ const REDACT_KEEP_KEYS = new Set([
1589
1587
'content' , 'unsigned' , 'origin_server_ts' ,
1590
1588
] ) ;
1591
1589
1592
- // a map from event type to the .content keys we keep when an event is redacted
1590
+ // a map from state event type to the .content keys we keep when an event is redacted
1593
1591
const REDACT_KEEP_CONTENT_MAP = {
1594
1592
[ EventType . RoomMember ] : { 'membership' : 1 } ,
1595
1593
[ EventType . RoomCreate ] : { 'creator' : 1 } ,
0 commit comments