1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-26 17:03:12 +03:00

Make crypto.decryptMessage return decryption results

... instead of having it call event.setClearData.

The main advantage of this is that it fixes a race condition, wherein apps
could see `event.isDecrypting()` to be true, but in fact the event had been
decrypted (and there was no `Event.decrypted` event on its way).

We're also fixing another race, wherein if the first attempt to decrypt failed,
a call to `attemptDecryption` would race against the first call and a second
attempt to decrypt would never happen.

This also gives a cleaner interface to MatrixEvent, at the expense of making
the `megolm` unit test a bit more hoop-jumpy.
This commit is contained in:
Richard van der Hoff
2017-08-09 17:34:45 +01:00
parent 9550bca099
commit 6613ee6b0d
7 changed files with 227 additions and 83 deletions

View File

@@ -117,7 +117,8 @@ class DecryptionAlgorithm {
*
* @param {MatrixEvent} event undecrypted event
*
* @return {Promise} resolves once we have finished decrypting. Rejects with an
* @return {Promise<module:crypto~EventDecryptionResult>} promise which
* resolves once we have finished decrypting. Rejects with an
* `algorithms.DecryptionError` if there is a problem decrypting the event.
*/