You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-25 05:23:13 +03:00
Prune both clear & wire content on redaction (#2346)
This commit is contained in:
committed by
GitHub
parent
dea3f52fe9
commit
6b5f4aa0a9
@@ -1112,23 +1112,21 @@ export class MatrixEvent extends TypedEventEmitter<EmittedEvents, MatrixEventHan
|
||||
}
|
||||
this.event.unsigned.redacted_because = redactionEvent.event as IEvent;
|
||||
|
||||
let key;
|
||||
for (key in this.event) {
|
||||
if (!this.event.hasOwnProperty(key)) {
|
||||
continue;
|
||||
}
|
||||
if (!REDACT_KEEP_KEYS.has(key)) {
|
||||
for (const key in this.event) {
|
||||
if (this.event.hasOwnProperty(key) && !REDACT_KEEP_KEYS.has(key)) {
|
||||
delete this.event[key];
|
||||
}
|
||||
}
|
||||
|
||||
// If the event is encrypted prune the decrypted bits
|
||||
if (this.isEncrypted()) {
|
||||
this.clearEvent = null;
|
||||
}
|
||||
|
||||
const keeps = REDACT_KEEP_CONTENT_MAP[this.getType()] || {};
|
||||
const content = this.getContent();
|
||||
for (key in content) {
|
||||
if (!content.hasOwnProperty(key)) {
|
||||
continue;
|
||||
}
|
||||
if (!keeps[key]) {
|
||||
for (const key in content) {
|
||||
if (content.hasOwnProperty(key) && !keeps[key]) {
|
||||
delete content[key];
|
||||
}
|
||||
}
|
||||
@@ -1589,7 +1587,7 @@ const REDACT_KEEP_KEYS = new Set([
|
||||
'content', 'unsigned', 'origin_server_ts',
|
||||
]);
|
||||
|
||||
// a map from event type to the .content keys we keep when an event is redacted
|
||||
// a map from state event type to the .content keys we keep when an event is redacted
|
||||
const REDACT_KEEP_CONTENT_MAP = {
|
||||
[EventType.RoomMember]: { 'membership': 1 },
|
||||
[EventType.RoomCreate]: { 'creator': 1 },
|
||||
|
||||
Reference in New Issue
Block a user