Skip to content

Commit 47e6527

Browse files
authored
Don't enable e2ee from profileViewer for bridge users (cinnyapp#666)
1 parent 7decbb6 commit 47e6527

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

src/app/organisms/invite-user/InviteUser.jsx

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import initMatrix from '../../../client/initMatrix';
66
import cons from '../../../client/state/cons';
77
import * as roomActions from '../../../client/action/room';
88
import { selectRoom } from '../../../client/action/navigation';
9-
import { hasDMWith } from '../../../util/matrixUtil';
9+
import { hasDMWith, hasDevices } from '../../../util/matrixUtil';
1010

1111
import Text from '../../atoms/text/Text';
1212
import Button from '../../atoms/button/Button';
@@ -103,18 +103,6 @@ function InviteUser({
103103
updateIsSearching(false);
104104
}
105105

106-
async function hasDevices(userId) {
107-
try {
108-
const usersDeviceMap = await mx.downloadKeys([userId, mx.getUserId()]);
109-
return Object.values(usersDeviceMap).every((userDevices) =>
110-
Object.keys(userDevices).length > 0,
111-
);
112-
} catch (e) {
113-
console.error("Error determining if it's possible to encrypt to all users: ", e);
114-
return false;
115-
}
116-
}
117-
118106
async function createDM(userId) {
119107
if (mx.getUserId() === userId) return;
120108
const dmRoomId = hasDMWith(userId);

src/app/organisms/profile-viewer/ProfileViewer.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { selectRoom, openReusableContextMenu } from '../../../client/action/navi
1111
import * as roomActions from '../../../client/action/room';
1212

1313
import {
14-
getUsername, getUsernameOfRoomMember, getPowerLabel, hasDMWith
14+
getUsername, getUsernameOfRoomMember, getPowerLabel, hasDMWith, hasDevices
1515
} from '../../../util/matrixUtil';
1616
import { getEventCords } from '../../../util/common';
1717
import colorMXID from '../../../util/colorMXID';
@@ -201,7 +201,7 @@ function ProfileFooter({ roomId, userId, onRequestClose }) {
201201
// Create new DM
202202
try {
203203
setIsCreatingDM(true);
204-
await roomActions.createDM(userId);
204+
await roomActions.createDM(userId, await hasDevices(userId));
205205
} catch {
206206
if (isMountedRef.current === false) return;
207207
setIsCreatingDM(false);

src/util/matrixUtil.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,3 +199,16 @@ export function getSSKeyInfo(key) {
199199
return undefined;
200200
}
201201
}
202+
203+
export async function hasDevices(userId) {
204+
const mx = initMatrix.matrixClient;
205+
try {
206+
const usersDeviceMap = await mx.downloadKeys([userId, mx.getUserId()]);
207+
return Object.values(usersDeviceMap).every((userDevices) =>
208+
Object.keys(userDevices).length > 0,
209+
);
210+
} catch (e) {
211+
console.error("Error determining if it's possible to encrypt to all users: ", e);
212+
return false;
213+
}
214+
}

0 commit comments

Comments
 (0)