Bug 1838927 - Fix detection of encryption for new Matrix DMs. r=freaktechnik

Differential Revision: https://phabricator.services.mozilla.com/D181284

--HG--
extra : amend_source : 18e80f5461b033e20030ea9b205d3d44d29d589a
This commit is contained in:
Patrick Cloke 2023-06-23 08:54:30 +10:00
Родитель ef6da9ea92
Коммит ac479432ff
1 изменённых файлов: 5 добавлений и 3 удалений

Просмотреть файл

@ -3314,9 +3314,11 @@ MatrixAccount.prototype = {
if (roomInit.is_direct && roomInit.invite) {
try {
const userDeviceMap = await this._client.downloadKeys(roomInit.invite);
const shouldEncrypt = Object.values(userDeviceMap).every(
deviceMap => Object.keys(deviceMap).length > 0
);
// Encrypt if there are devices and each user has at least 1 device
// capable of encryption.
const shouldEncrypt =
userDeviceMap.size > 0 &&
[...userDeviceMap.values()].every(deviceMap => deviceMap.size > 0);
if (shouldEncrypt) {
if (!roomInit.initial_state) {
roomInit.initial_state = [];