You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-08-24 02:33:02 +03:00
Don't try to decrypt end-to-end messages if the client doesn't have end-to-end support enabled
This commit is contained in:
@@ -662,6 +662,12 @@ function _sendEncryptedMessage(client, roomId, e2eRoomInfo, eventType, content,
|
||||
}
|
||||
|
||||
function _decryptMessage(client, event) {
|
||||
if (client.sessionStore === null) {
|
||||
// End to end encryption isn't enabled if we don't have a session
|
||||
// store.
|
||||
return _badEncryptedMessage(event, "Encryption not enabled");
|
||||
}
|
||||
|
||||
var content = event.getContent();
|
||||
if (content.algorithm === OLM_ALGORITHM) {
|
||||
var sender = event.getSender();
|
||||
@@ -726,12 +732,12 @@ function _decryptMessage(client, event) {
|
||||
user_id: event.getSender()
|
||||
});
|
||||
} else {
|
||||
return _badEncryptedMessge(event, "Bad Encrypted Message");
|
||||
return _badEncryptedMessage(event, "Bad Encrypted Message");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _badEncryptedMessge(event, reason) {
|
||||
function _badEncryptedMessage(event, reason) {
|
||||
return new MatrixEvent({
|
||||
type: "m.room.message",
|
||||
// TODO: Add rest of the event keys.
|
||||
|
Reference in New Issue
Block a user