Merge branch 'krille/request-keys' into 'main'
feat: Allow auto request keys via key sharing requests See merge request famedly/company/frontend/famedlysdk!1116
This commit is contained in:
commit
76a94e0319
|
|
@ -226,7 +226,13 @@ class KeyManager {
|
|||
}
|
||||
|
||||
/// Attempt auto-request for a key
|
||||
void maybeAutoRequest(String roomId, String sessionId, String senderKey) {
|
||||
void maybeAutoRequest(
|
||||
String roomId,
|
||||
String sessionId,
|
||||
String senderKey, {
|
||||
bool tryOnlineBackup = true,
|
||||
bool onlineKeyBackupOnly = true,
|
||||
}) {
|
||||
final room = client.getRoomById(roomId);
|
||||
final requestIdent = '$roomId|$sessionId|$senderKey';
|
||||
if (room != null &&
|
||||
|
|
@ -234,8 +240,13 @@ class KeyManager {
|
|||
!client.isUnknownSession) {
|
||||
// do e2ee recovery
|
||||
_requestedSessionIds.add(requestIdent);
|
||||
runInRoot(
|
||||
() => request(room, sessionId, senderKey, onlineKeyBackupOnly: true));
|
||||
runInRoot(() => request(
|
||||
room,
|
||||
sessionId,
|
||||
senderKey,
|
||||
tryOnlineBackup: tryOnlineBackup,
|
||||
onlineKeyBackupOnly: onlineKeyBackupOnly,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -333,14 +333,22 @@ class Timeline {
|
|||
}
|
||||
|
||||
/// Request the keys for undecryptable events of this timeline
|
||||
void requestKeys() {
|
||||
void requestKeys({
|
||||
bool tryOnlineBackup = true,
|
||||
bool onlineKeyBackupOnly = true,
|
||||
}) {
|
||||
for (final event in events) {
|
||||
if (event.type == EventTypes.Encrypted &&
|
||||
event.messageType == MessageTypes.BadEncrypted &&
|
||||
event.content['can_request_session'] == true) {
|
||||
try {
|
||||
room.client.encryption?.keyManager.maybeAutoRequest(room.id,
|
||||
event.content['session_id'], event.content['sender_key']);
|
||||
room.client.encryption?.keyManager.maybeAutoRequest(
|
||||
room.id,
|
||||
event.content['session_id'],
|
||||
event.content['sender_key'],
|
||||
tryOnlineBackup: tryOnlineBackup,
|
||||
onlineKeyBackupOnly: onlineKeyBackupOnly,
|
||||
);
|
||||
} catch (_) {
|
||||
// dispose
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue