Merge branch 'malin/refactorVariableNaming' into 'main'
refactor: Rename one-character-variables in device_keys_list.dart See merge request famedly/company/frontend/famedlysdk!1259
This commit is contained in:
commit
da61963d37
|
|
@ -36,8 +36,8 @@ class DeviceKeysList {
|
||||||
|
|
||||||
SignableKey? getKey(String id) => deviceKeys[id] ?? crossSigningKeys[id];
|
SignableKey? getKey(String id) => deviceKeys[id] ?? crossSigningKeys[id];
|
||||||
|
|
||||||
CrossSigningKey? getCrossSigningKey(String type) =>
|
CrossSigningKey? getCrossSigningKey(String type) => crossSigningKeys.values
|
||||||
crossSigningKeys.values.firstWhereOrNull((k) => k.usage.contains(type));
|
.firstWhereOrNull((key) => key.usage.contains(type));
|
||||||
|
|
||||||
CrossSigningKey? get masterKey => getCrossSigningKey('master');
|
CrossSigningKey? get masterKey => getCrossSigningKey('master');
|
||||||
CrossSigningKey? get selfSigningKey => getCrossSigningKey('self_signing');
|
CrossSigningKey? get selfSigningKey => getCrossSigningKey('self_signing');
|
||||||
|
|
@ -106,9 +106,8 @@ class DeviceKeysList {
|
||||||
Map<String, dynamic> dbEntry,
|
Map<String, dynamic> dbEntry,
|
||||||
List<Map<String, dynamic>> childEntries,
|
List<Map<String, dynamic>> childEntries,
|
||||||
List<Map<String, dynamic>> crossSigningEntries,
|
List<Map<String, dynamic>> crossSigningEntries,
|
||||||
Client cl)
|
this.client)
|
||||||
: client = cl,
|
: userId = dbEntry['user_id'] ?? '' {
|
||||||
userId = dbEntry['user_id'] ?? '' {
|
|
||||||
outdated = dbEntry['outdated'];
|
outdated = dbEntry['outdated'];
|
||||||
deviceKeys = {};
|
deviceKeys = {};
|
||||||
for (final childEntry in childEntries) {
|
for (final childEntry in childEntries) {
|
||||||
|
|
@ -149,7 +148,7 @@ abstract class SignableKey extends MatrixSignableKey {
|
||||||
bool get verified =>
|
bool get verified =>
|
||||||
identifier != null && (directVerified || crossVerified) && !(blocked);
|
identifier != null && (directVerified || crossVerified) && !(blocked);
|
||||||
bool get blocked => _blocked ?? false;
|
bool get blocked => _blocked ?? false;
|
||||||
set blocked(bool b) => _blocked = b;
|
set blocked(bool isBlocked) => _blocked = isBlocked;
|
||||||
|
|
||||||
bool get encryptToDevice {
|
bool get encryptToDevice {
|
||||||
if (blocked) return false;
|
if (blocked) return false;
|
||||||
|
|
@ -159,17 +158,16 @@ abstract class SignableKey extends MatrixSignableKey {
|
||||||
return client.shareKeysWithUnverifiedDevices || verified;
|
return client.shareKeysWithUnverifiedDevices || verified;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDirectVerified(bool v) {
|
void setDirectVerified(bool isVerified) {
|
||||||
_verified = v;
|
_verified = isVerified;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get directVerified => _verified ?? false;
|
bool get directVerified => _verified ?? false;
|
||||||
bool get crossVerified => hasValidSignatureChain();
|
bool get crossVerified => hasValidSignatureChain();
|
||||||
bool get signed => hasValidSignatureChain(verifiedOnly: false);
|
bool get signed => hasValidSignatureChain(verifiedOnly: false);
|
||||||
|
|
||||||
SignableKey.fromJson(Map<String, dynamic> json, Client cl)
|
SignableKey.fromJson(Map<String, dynamic> json, this.client)
|
||||||
: client = cl,
|
: super.fromJson(json) {
|
||||||
super.fromJson(json) {
|
|
||||||
_verified = false;
|
_verified = false;
|
||||||
_blocked = false;
|
_blocked = false;
|
||||||
}
|
}
|
||||||
|
|
@ -392,15 +390,16 @@ class CrossSigningKey extends SignableKey {
|
||||||
?.setBlockedUserCrossSigningKey(newBlocked, userId, publicKey!);
|
?.setBlockedUserCrossSigningKey(newBlocked, userId, publicKey!);
|
||||||
}
|
}
|
||||||
|
|
||||||
CrossSigningKey.fromMatrixCrossSigningKey(MatrixCrossSigningKey k, Client cl)
|
CrossSigningKey.fromMatrixCrossSigningKey(
|
||||||
: super.fromJson(k.toJson().copy(), cl) {
|
MatrixCrossSigningKey key, Client client)
|
||||||
|
: super.fromJson(key.toJson().copy(), client) {
|
||||||
final json = toJson();
|
final json = toJson();
|
||||||
identifier = k.publicKey;
|
identifier = key.publicKey;
|
||||||
usage = json['usage'].cast<String>();
|
usage = json['usage'].cast<String>();
|
||||||
}
|
}
|
||||||
|
|
||||||
CrossSigningKey.fromDbJson(Map<String, dynamic> dbEntry, Client cl)
|
CrossSigningKey.fromDbJson(Map<String, dynamic> dbEntry, Client client)
|
||||||
: super.fromJson(Event.getMapFromPayload(dbEntry['content']), cl) {
|
: super.fromJson(Event.getMapFromPayload(dbEntry['content']), client) {
|
||||||
final json = toJson();
|
final json = toJson();
|
||||||
identifier = dbEntry['public_key'];
|
identifier = dbEntry['public_key'];
|
||||||
usage = json['usage'].cast<String>();
|
usage = json['usage'].cast<String>();
|
||||||
|
|
@ -408,8 +407,8 @@ class CrossSigningKey extends SignableKey {
|
||||||
_blocked = dbEntry['blocked'];
|
_blocked = dbEntry['blocked'];
|
||||||
}
|
}
|
||||||
|
|
||||||
CrossSigningKey.fromJson(Map<String, dynamic> json, Client cl)
|
CrossSigningKey.fromJson(Map<String, dynamic> json, Client client)
|
||||||
: super.fromJson(json.copy(), cl) {
|
: super.fromJson(json.copy(), client) {
|
||||||
final json = toJson();
|
final json = toJson();
|
||||||
usage = json['usage'].cast<String>();
|
usage = json['usage'].cast<String>();
|
||||||
if (keys.isNotEmpty) {
|
if (keys.isNotEmpty) {
|
||||||
|
|
@ -476,17 +475,17 @@ class DeviceKeys extends SignableKey {
|
||||||
?.setBlockedUserDeviceKey(newBlocked, userId, deviceId!);
|
?.setBlockedUserDeviceKey(newBlocked, userId, deviceId!);
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceKeys.fromMatrixDeviceKeys(MatrixDeviceKeys k, Client cl,
|
DeviceKeys.fromMatrixDeviceKeys(MatrixDeviceKeys keys, Client client,
|
||||||
[DateTime? lastActiveTs])
|
[DateTime? lastActiveTs])
|
||||||
: super.fromJson(k.toJson().copy(), cl) {
|
: super.fromJson(keys.toJson().copy(), client) {
|
||||||
final json = toJson();
|
final json = toJson();
|
||||||
identifier = k.deviceId;
|
identifier = keys.deviceId;
|
||||||
algorithms = json['algorithms'].cast<String>();
|
algorithms = json['algorithms'].cast<String>();
|
||||||
lastActive = lastActiveTs ?? DateTime.now();
|
lastActive = lastActiveTs ?? DateTime.now();
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceKeys.fromDb(Map<String, dynamic> dbEntry, Client cl)
|
DeviceKeys.fromDb(Map<String, dynamic> dbEntry, Client client)
|
||||||
: super.fromJson(Event.getMapFromPayload(dbEntry['content']), cl) {
|
: super.fromJson(Event.getMapFromPayload(dbEntry['content']), client) {
|
||||||
final json = toJson();
|
final json = toJson();
|
||||||
identifier = dbEntry['device_id'];
|
identifier = dbEntry['device_id'];
|
||||||
algorithms = json['algorithms'].cast<String>();
|
algorithms = json['algorithms'].cast<String>();
|
||||||
|
|
@ -496,8 +495,8 @@ class DeviceKeys extends SignableKey {
|
||||||
DateTime.fromMillisecondsSinceEpoch(dbEntry['last_active'] ?? 0);
|
DateTime.fromMillisecondsSinceEpoch(dbEntry['last_active'] ?? 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceKeys.fromJson(Map<String, dynamic> json, Client cl)
|
DeviceKeys.fromJson(Map<String, dynamic> json, Client client)
|
||||||
: super.fromJson(json.copy(), cl) {
|
: super.fromJson(json.copy(), client) {
|
||||||
final json = toJson();
|
final json = toJson();
|
||||||
identifier = json['device_id'];
|
identifier = json['device_id'];
|
||||||
algorithms = json['algorithms'].cast<String>();
|
algorithms = json['algorithms'].cast<String>();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue