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) { if (key == null || signedWith == null || signature == null) {
return; return;
} }
final signedKey = signedKeys.firstWhere( final signedKey = key.cloneForSigning();
(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>{}; signedKey.signatures[signedWith.userId] = <String, String>{};
}
signedKey.signatures[signedWith.userId] signedKey.signatures[signedWith.userId]
['ed25519:${signedWith.identifier}'] = signature; ['ed25519:${signedWith.identifier}'] = signature;
signedKeys.add(signedKey); signedKeys.add(signedKey);

View file

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