put key request in try...catch

This commit is contained in:
Sorunome 2020-08-01 07:06:39 +00:00 committed by Christian Pauly
parent 2697f88397
commit 18a790be84
1 changed files with 32 additions and 27 deletions

View File

@ -417,34 +417,39 @@ class KeyManager {
return; // we managed to load the session from online backup, no need to care about it now return; // we managed to load the session from online backup, no need to care about it now
} }
} }
// while we just send the to-device event to '*', we still need to save the try {
// devices themself to know where to send the cancel to after receiving a reply // while we just send the to-device event to '*', we still need to save the
final devices = await room.getUserDeviceKeys(); // devices themself to know where to send the cancel to after receiving a reply
final requestId = client.generateUniqueTransactionId(); final devices = await room.getUserDeviceKeys();
final request = KeyManagerKeyShareRequest( final requestId = client.generateUniqueTransactionId();
requestId: requestId, final request = KeyManagerKeyShareRequest(
devices: devices, requestId: requestId,
room: room, devices: devices,
sessionId: sessionId, room: room,
senderKey: senderKey, sessionId: sessionId,
); senderKey: senderKey,
await client.sendToDevice( );
[], await client.sendToDevice(
'm.room_key_request', [],
{ 'm.room_key_request',
'action': 'request', {
'body': { 'action': 'request',
'algorithm': 'm.megolm.v1.aes-sha2', 'body': {
'room_id': room.id, 'algorithm': 'm.megolm.v1.aes-sha2',
'sender_key': senderKey, 'room_id': room.id,
'session_id': sessionId, 'sender_key': senderKey,
'session_id': sessionId,
},
'request_id': requestId,
'requesting_device_id': client.deviceID,
}, },
'request_id': requestId, encrypted: false,
'requesting_device_id': client.deviceID, toUsers: await room.requestParticipants());
}, outgoingShareRequests[request.requestId] = request;
encrypted: false, } catch (err) {
toUsers: await room.requestParticipants()); print('[Key Manager] Sending key verification request failed: ' +
outgoingShareRequests[request.requestId] = request; err.toString());
}
} }
/// Handle an incoming to_device event that is related to key sharing /// Handle an incoming to_device event that is related to key sharing