1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-28 05:03:59 +03:00

delintificate

This commit is contained in:
Richard van der Hoff
2016-02-16 16:14:45 +00:00
parent 6f3bdcfbb6
commit 6a6db36088

View File

@@ -204,14 +204,17 @@ module.exports.MatrixEvent.prototype = {
} }
this.event.unsigned.redacted_because = redaction_event; this.event.unsigned.redacted_because = redaction_event;
for (var key in utils.keys(this.event)) { var key;
for (key in this.event) {
if (!this.event.hasOwnProperty(key)) { continue; }
if (!_REDACT_KEEP_KEY_MAP[key]) { if (!_REDACT_KEEP_KEY_MAP[key]) {
delete this.event[key]; delete this.event[key];
} }
} }
var keeps = _REDACT_KEEP_CONTENT_MAP[this.getType()] || {}; var keeps = _REDACT_KEEP_CONTENT_MAP[this.getType()] || {};
for (var key in utils.keys(this.event.content)) { for (key in this.event.content) {
if (!this.event.content.hasOwnProperty(key)) { continue; }
if (!keeps[key]) { if (!keeps[key]) {
delete this.event.content[key]; delete this.event.content[key];
} }
@@ -241,17 +244,20 @@ module.exports.MatrixEvent.prototype = {
* content * content
* [we keep 'unsigned' as well, since that is created by the local server] * [we keep 'unsigned' as well, since that is created by the local server]
* *
* The content object should also be stripped of all keys, unless it is one of one of the following event types: * The content object should also be stripped of all keys, unless it is one of
* one of the following event types:
* m.room.member allows key membership * m.room.member allows key membership
* m.room.create allows key creator * m.room.create allows key creator
* m.room.join_rules allows key join_rule * m.room.join_rules allows key join_rule
* m.room.power_levels allows keys ban, events, events_default, kick, redact, state_default, users, users_default. * m.room.power_levels allows keys ban, events, events_default, kick,
* redact, state_default, users, users_default.
* m.room.aliases allows key aliases * m.room.aliases allows key aliases
*/ */
// a map giving the keys we keep when an event is redacted // a map giving the keys we keep when an event is redacted
var _REDACT_KEEP_KEY_MAP = [ var _REDACT_KEEP_KEY_MAP = [
'event_id', 'type', 'room_id', 'user_id', 'state_key', 'prev_state', 'content', 'unsigned', 'event_id', 'type', 'room_id', 'user_id', 'state_key', 'prev_state',
].reduce(function(ret, val) { ret[val] = 1; return ret}, {}); 'content', 'unsigned',
].reduce(function(ret, val) { ret[val] = 1; return ret; }, {});
// a map from event type to the .content keys we keep when an event is redacted // a map from event type to the .content keys we keep when an event is redacted
var _REDACT_KEEP_CONTENT_MAP = { var _REDACT_KEEP_CONTENT_MAP = {