Merge branch 'td/fixNull' into 'main'
chore: fix unexpected null when device is not known See merge request famedly/company/frontend/famedlysdk!1318
This commit is contained in:
commit
224c14c7ae
|
|
@ -233,7 +233,6 @@ class KeyVerification {
|
||||||
canceled ||
|
canceled ||
|
||||||
{KeyVerificationState.error, KeyVerificationState.done}.contains(state);
|
{KeyVerificationState.error, KeyVerificationState.done}.contains(state);
|
||||||
|
|
||||||
String? chosenMethod;
|
|
||||||
// qr stuff
|
// qr stuff
|
||||||
QRCode? qrCode;
|
QRCode? qrCode;
|
||||||
String? randomSharedSecretForQRCode;
|
String? randomSharedSecretForQRCode;
|
||||||
|
|
@ -293,7 +292,6 @@ class KeyVerification {
|
||||||
/// qr, send the qrData you just scanned
|
/// qr, send the qrData you just scanned
|
||||||
Future<void> continueVerification(String type,
|
Future<void> continueVerification(String type,
|
||||||
{Uint8List? qrDataRawBytes}) async {
|
{Uint8List? qrDataRawBytes}) async {
|
||||||
chosenMethod = type;
|
|
||||||
bool qrChecksOut = false;
|
bool qrChecksOut = false;
|
||||||
if (possibleMethods.contains(type)) {
|
if (possibleMethods.contains(type)) {
|
||||||
if (qrDataRawBytes != null) {
|
if (qrDataRawBytes != null) {
|
||||||
|
|
@ -411,7 +409,7 @@ class KeyVerification {
|
||||||
|
|
||||||
setState(KeyVerificationState.askAccept);
|
setState(KeyVerificationState.askAccept);
|
||||||
break;
|
break;
|
||||||
case 'm.key.verification.ready':
|
case EventTypes.KeyVerificationReady:
|
||||||
if (deviceId == '*') {
|
if (deviceId == '*') {
|
||||||
_deviceId = payload['from_device']; // gotta set the real device id
|
_deviceId = payload['from_device']; // gotta set the real device id
|
||||||
transactionId ??= eventId ?? payload['transaction_id'];
|
transactionId ??= eventId ?? payload['transaction_id'];
|
||||||
|
|
@ -498,7 +496,7 @@ class KeyVerification {
|
||||||
}
|
}
|
||||||
if (!(await verifyLastStep([
|
if (!(await verifyLastStep([
|
||||||
EventTypes.KeyVerificationRequest,
|
EventTypes.KeyVerificationRequest,
|
||||||
'm.key.verification.ready',
|
EventTypes.KeyVerificationReady,
|
||||||
]))) {
|
]))) {
|
||||||
return; // abort
|
return; // abort
|
||||||
}
|
}
|
||||||
|
|
@ -642,7 +640,7 @@ class KeyVerification {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// we need to send a ready event
|
// we need to send a ready event
|
||||||
await send('m.key.verification.ready', {
|
await send(EventTypes.KeyVerificationReady, {
|
||||||
'methods': copyKnownVerificationMethods,
|
'methods': copyKnownVerificationMethods,
|
||||||
});
|
});
|
||||||
// setup QRData from incoming request (outgoing ready)
|
// setup QRData from incoming request (outgoing ready)
|
||||||
|
|
@ -938,13 +936,14 @@ class KeyVerification {
|
||||||
'[Key Verification] Tried to broadcast and un-broadcastable type: $type');
|
'[Key Verification] Tried to broadcast and un-broadcastable type: $type');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (client.userDeviceKeys[userId]?.deviceKeys[deviceId] == null) {
|
if (client.userDeviceKeys[userId]?.deviceKeys[deviceId] != null) {
|
||||||
|
await client.sendToDeviceEncrypted(
|
||||||
|
[client.userDeviceKeys[userId]!.deviceKeys[deviceId]!],
|
||||||
|
type,
|
||||||
|
payload);
|
||||||
|
} else {
|
||||||
Logs().e('[Key Verification] Unknown device');
|
Logs().e('[Key Verification] Unknown device');
|
||||||
}
|
}
|
||||||
await client.sendToDeviceEncrypted(
|
|
||||||
[client.userDeviceKeys[userId]!.deviceKeys[deviceId]!],
|
|
||||||
type,
|
|
||||||
payload);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1128,7 +1127,7 @@ class _KeyVerificationMethodQRReciprocate extends _KeyVerificationMethod {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case EventTypes.KeyVerificationStart:
|
case EventTypes.KeyVerificationStart:
|
||||||
if (!(await request.verifyLastStep([
|
if (!(await request.verifyLastStep([
|
||||||
'm.key.verification.ready',
|
EventTypes.KeyVerificationReady,
|
||||||
EventTypes.KeyVerificationRequest,
|
EventTypes.KeyVerificationRequest,
|
||||||
]))) {
|
]))) {
|
||||||
return; // abort
|
return; // abort
|
||||||
|
|
@ -1247,7 +1246,7 @@ class _KeyVerificationMethodSas extends _KeyVerificationMethod {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case EventTypes.KeyVerificationStart:
|
case EventTypes.KeyVerificationStart:
|
||||||
if (!(await request.verifyLastStep([
|
if (!(await request.verifyLastStep([
|
||||||
'm.key.verification.ready',
|
EventTypes.KeyVerificationReady,
|
||||||
EventTypes.KeyVerificationRequest,
|
EventTypes.KeyVerificationRequest,
|
||||||
EventTypes.KeyVerificationStart
|
EventTypes.KeyVerificationStart
|
||||||
]))) {
|
]))) {
|
||||||
|
|
@ -1261,7 +1260,7 @@ class _KeyVerificationMethodSas extends _KeyVerificationMethod {
|
||||||
break;
|
break;
|
||||||
case EventTypes.KeyVerificationAccept:
|
case EventTypes.KeyVerificationAccept:
|
||||||
if (!(await request.verifyLastStep([
|
if (!(await request.verifyLastStep([
|
||||||
'm.key.verification.ready',
|
EventTypes.KeyVerificationReady,
|
||||||
EventTypes.KeyVerificationRequest
|
EventTypes.KeyVerificationRequest
|
||||||
]))) {
|
]))) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -518,7 +518,7 @@ void main() async {
|
||||||
.handleEventUpdate(EventUpdate(
|
.handleEventUpdate(EventUpdate(
|
||||||
content: {
|
content: {
|
||||||
'event_id': req2.transactionId,
|
'event_id': req2.transactionId,
|
||||||
'type': 'm.key.verification.ready',
|
'type': EventTypes.KeyVerificationReady,
|
||||||
'content': {
|
'content': {
|
||||||
'methods': [EventTypes.Sas],
|
'methods': [EventTypes.Sas],
|
||||||
'from_device': 'SOMEOTHERDEVICE',
|
'from_device': 'SOMEOTHERDEVICE',
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ void main() async {
|
||||||
}
|
}
|
||||||
await req1.client.encryption!.keyVerificationManager.handleToDeviceEvent(
|
await req1.client.encryption!.keyVerificationManager.handleToDeviceEvent(
|
||||||
ToDeviceEvent(
|
ToDeviceEvent(
|
||||||
type: 'm.key.verification.ready',
|
type: EventTypes.KeyVerificationReady,
|
||||||
sender: req2.client.userID!,
|
sender: req2.client.userID!,
|
||||||
content: {
|
content: {
|
||||||
'from_device': req2.client.deviceID,
|
'from_device': req2.client.deviceID,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue