src/models/event.js
function(redaction_event) {
        // quick sanity-check
        if (!redaction_event.event) {
            throw new Error("invalid redaction_event in makeRedacted");
        }

        // we attempt to replicate what we would see from the server if
        // the event had been redacted before we saw it.
        //
        // The server removes (most of) the content of the event, and adds a
        // "redacted_because" key to the unsigned section containing the
        // redacted event.
        if (!this.event.unsigned) {
            this.event.unsigned = {};
        }
        this.event.unsigned.redacted_because = redaction_event.event;

        let key;
        for (key in this.event) {
            if (!this.event.hasOwnProperty(key)) {
                continue;
            }
            if (!_REDACT_KEEP_KEY_MAP[key]) {
                delete this.event[key];
            }
        }

        const keeps = _REDACT_KEEP_CONTENT_MAP[this.getType()] || {};
        const content = this.getContent();
        for (key in content) {
            if (!content.hasOwnProperty(key)) {
                continue;
            }
            if (!keeps[key]) {
                delete content[key];
            }
        }
    }
function(redaction_event) {
        // quick sanity-check
        if (!redaction_event.event) {
            throw new Error("invalid redaction_event in makeRedacted");
        }

        // we attempt to replicate what we would see from the server if
        // the event had been redacted before we saw it.
        //
        // The server removes (most of) the content of the event, and adds a
        // "redacted_because" key to the unsigned section containing the
        // redacted event.
        if (!this.event.unsigned) {
            this.event.unsigned = {};
        }
        this.event.unsigned.redacted_because = redaction_event.event;

        let key;
        for (key in this.event) {
            if (!this.event.hasOwnProperty(key)) {
                continue;
            }
            if (!_REDACT_KEEP_KEY_MAP[key]) {
                delete this.event[key];
            }
        }

        const keeps = _REDACT_KEEP_CONTENT_MAP[this.getType()] || {};
        const content = this.getContent();
        for (key in content) {
            if (!content.hasOwnProperty(key)) {
                continue;
            }
            if (!keeps[key]) {
                delete content[key];
            }
        }
    }
function ( redaction_event ) { // quick sanity-check if ( ! redaction_event . event ) { throw new Error ( "invalid redaction_event in makeRedacted" ) ; } // we attempt to replicate what we would see from the server if // the event had been redacted before we saw it. // // The server removes (most of) the content of the event, and adds a // "redacted_because" key to the unsigned section containing the // redacted event. if ( ! this . event . unsigned ) { this . event . unsigned = { } ; } this . event . unsigned . redacted_because = redaction_event . event ; let key ; for ( key in this . event ) { if ( ! this . event . hasOwnProperty ( key ) ) { continue ; } if ( ! _REDACT_KEEP_KEY_MAP [ key ] ) { delete this . event [ key ] ; } } const keeps = _REDACT_KEEP_CONTENT_MAP [ this . getType ( ) ] || { } ; const content = this . getContent ( ) ; for ( key in content ) { if ( ! content . hasOwnProperty ( key ) ) { continue ; } if ( ! keeps [ key ] ) { delete content [ key ] ; } } }
Update the content of an event in the same way it would be by the server
if it were redacted before it was sent to us

@param {module:models/event.MatrixEvent} redaction_event
event causing the redaction
Update the content of an event in the same way it would be by the server if it were redacted before it was sent to us