src/models/event.js
async function(crypto) {
        // start with a couple of sanity checks.
        if (!this.isEncrypted()) {
            throw new Error("Attempt to decrypt event which isn't encrypted");
        }

        if (
            this._clearEvent && this._clearEvent.content &&
                this._clearEvent.content.msgtype !== "m.bad.encrypted"
        ) {
            // we may want to just ignore this? let's start with rejecting it.
            throw new Error(
                "Attempt to decrypt event which has already been encrypted",
            );
        }

        // if we already have a decryption attempt in progress, then it may
        // fail because it was using outdated info. We now have reason to
        // succeed where it failed before, but we don't want to have multiple
        // attempts going at the same time, so just set a flag that says we have
        // new info.
        //
        if (this._decryptionPromise) {
            console.log(
                `Event ${this.getId()} already being decrypted; queueing a retry`,
            );
            this._retryDecryption = true;
            return this._decryptionPromise;
        }

        this._decryptionPromise = this._decryptionLoop(crypto);
        return this._decryptionPromise;
    }
async function(crypto) {
        // start with a couple of sanity checks.
        if (!this.isEncrypted()) {
            throw new Error("Attempt to decrypt event which isn't encrypted");
        }

        if (
            this._clearEvent && this._clearEvent.content &&
                this._clearEvent.content.msgtype !== "m.bad.encrypted"
        ) {
            // we may want to just ignore this? let's start with rejecting it.
            throw new Error(
                "Attempt to decrypt event which has already been encrypted",
            );
        }

        // if we already have a decryption attempt in progress, then it may
        // fail because it was using outdated info. We now have reason to
        // succeed where it failed before, but we don't want to have multiple
        // attempts going at the same time, so just set a flag that says we have
        // new info.
        //
        if (this._decryptionPromise) {
            console.log(
                `Event ${this.getId()} already being decrypted; queueing a retry`,
            );
            this._retryDecryption = true;
            return this._decryptionPromise;
        }

        this._decryptionPromise = this._decryptionLoop(crypto);
        return this._decryptionPromise;
    }
async function ( crypto ) { // start with a couple of sanity checks. if ( ! this . isEncrypted ( ) ) { throw new Error ( "Attempt to decrypt event which isn't encrypted" ) ; } if ( this . _clearEvent && this . _clearEvent . content && this . _clearEvent . content . msgtype !== "m.bad.encrypted" ) { // we may want to just ignore this? let's start with rejecting it. throw new Error ( "Attempt to decrypt event which has already been encrypted" , ) ; } // if we already have a decryption attempt in progress, then it may // fail because it was using outdated info. We now have reason to // succeed where it failed before, but we don't want to have multiple // attempts going at the same time, so just set a flag that says we have // new info. // if ( this . _decryptionPromise ) { console . log ( ` ${ this . getId ( ) } ` , ) ; this . _retryDecryption = true ; return this . _decryptionPromise ; } this . _decryptionPromise = this . _decryptionLoop ( crypto ) ; return this . _decryptionPromise ; }
Start the process of trying to decrypt this event.

(This is used within the SDK: it isn't intended for use by applications)

@internal

@param {module:crypto} crypto crypto module

@returns {Promise} promise which resolves (to undefined) when the decryption
attempt is completed.
Start the process of trying to decrypt this event .