fix: Ask only own devices on automated key requests

This commit is contained in:
Christian Pauly 2020-09-16 13:42:05 +02:00
parent b05e4da34f
commit df2cfb3faf

View file

@ -207,7 +207,7 @@ class KeyManager {
!_requestedSessionIds.contains(requestIdent)) { !_requestedSessionIds.contains(requestIdent)) {
// do e2ee recovery // do e2ee recovery
_requestedSessionIds.add(requestIdent); _requestedSessionIds.add(requestIdent);
unawaited(request(room, sessionId, senderKey)); unawaited(request(room, sessionId, senderKey, askOnlyOwnDevices: true));
} }
return null; return null;
} }
@ -442,8 +442,13 @@ class KeyManager {
} }
/// Request a certain key from another device /// Request a certain key from another device
Future<void> request(Room room, String sessionId, String senderKey, Future<void> request(
{bool tryOnlineBackup = true}) async { Room room,
String sessionId,
String senderKey, {
bool tryOnlineBackup = true,
bool askOnlyOwnDevices = false,
}) async {
if (tryOnlineBackup) { if (tryOnlineBackup) {
// let's first check our online key backup store thingy... // let's first check our online key backup store thingy...
var hadPreviously = var hadPreviously =
@ -470,6 +475,9 @@ class KeyManager {
// while we just send the to-device event to '*', we still need to save the // while we just send the to-device event to '*', we still need to save the
// devices themself to know where to send the cancel to after receiving a reply // devices themself to know where to send the cancel to after receiving a reply
final devices = await room.getUserDeviceKeys(); final devices = await room.getUserDeviceKeys();
if (askOnlyOwnDevices) {
devices.removeWhere((d) => d.userId != client.userID);
}
final requestId = client.generateUniqueTransactionId(); final requestId = client.generateUniqueTransactionId();
final request = KeyManagerKeyShareRequest( final request = KeyManagerKeyShareRequest(
requestId: requestId, requestId: requestId,