diff --git a/lib/client.js b/lib/client.js index 8ea538d69..1c52bf3fd 100644 --- a/lib/client.js +++ b/lib/client.js @@ -467,7 +467,7 @@ MatrixClient.prototype.isRoomEncrypted = function(roomId) { */ function _decryptEvent(client, event) { if (!client._crypto) { - _badEncryptedMessage(event, "**Encryption not enabled**"); + _badEncryptedMessage(event, "Encryption not enabled"); return; } @@ -477,7 +477,7 @@ function _decryptEvent(client, event) { if (!(e instanceof Crypto.DecryptionError)) { throw e; } - _badEncryptedMessage(event, "**" + e.message + "**"); + _badEncryptedMessage(event, e.message); return; } } @@ -487,7 +487,7 @@ function _badEncryptedMessage(event, reason) { type: "m.room.message", content: { msgtype: "m.bad.encrypted", - body: reason, + body: "** Unable to decrypt: " + reason + " **", }, }); } diff --git a/lib/crypto/algorithms/megolm.js b/lib/crypto/algorithms/megolm.js index da4ee7c8b..de112f202 100644 --- a/lib/crypto/algorithms/megolm.js +++ b/lib/crypto/algorithms/megolm.js @@ -458,7 +458,9 @@ MegolmDecryption.prototype.decryptEvent = function(event) { if (res === null) { // We've got a message for a session we don't have. this._addEventToPendingList(event); - throw new base.DecryptionError("Unknown inbound session id"); + throw new base.DecryptionError( + "The sender's device has not sent us the keys for this message." + ); } var payload = JSON.parse(res.result); diff --git a/lib/crypto/index.js b/lib/crypto/index.js index 3183e07e5..9bfeb3b23 100644 --- a/lib/crypto/index.js +++ b/lib/crypto/index.js @@ -1220,7 +1220,9 @@ Crypto.prototype._getRoomDecryptor = function(roomId, algorithm) { var AlgClass = algorithms.DECRYPTION_CLASSES[algorithm]; if (!AlgClass) { - throw new algorithms.DecryptionError("Unable to decrypt " + algorithm); + throw new algorithms.DecryptionError( + 'Unknown encryption algorithm "' + algorithm + '".' + ); } alg = new AlgClass({ userId: this._userId,