simplify key signing a tad

This commit is contained in:
Sorunome 2020-06-06 15:19:44 +02:00
parent b4e83caa89
commit 45232be3a0
No known key found for this signature in database
GPG Key ID: B19471D07FC9BE9C
2 changed files with 3 additions and 8 deletions

View File

@ -123,14 +123,8 @@ class CrossSigning {
if (key == null || signedWith == null || signature == null) {
return;
}
final signedKey = signedKeys.firstWhere(
(k) => k.userId == key.userId && k.identifier == key.identifier,
orElse: () => null) ??
key.cloneForSigning();
signedKey.signatures ??= <String, Map<String, String>>{};
if (!signedKey.signatures.containsKey(signedWith.userId)) {
signedKey.signatures[signedWith.userId] = <String, String>{};
}
final signedKey = key.cloneForSigning();
signedKey.signatures[signedWith.userId] = <String, String>{};
signedKey.signatures[signedWith.userId]
['ed25519:${signedWith.identifier}'] = signature;
signedKeys.add(signedKey);

View File

@ -125,6 +125,7 @@ abstract class SignableKey extends MatrixSignableKey {
MatrixSignableKey cloneForSigning() {
final newKey =
MatrixSignableKey.fromJson(Map<String, dynamic>.from(toJson()));
newKey.signatures ??= <String, Map<String, String>>{};
newKey.signatures.clear();
return newKey;
}