chore: cleanup some eventTypes and unused variables

This commit is contained in:
td 2023-06-27 13:46:39 +05:30
parent bfda82bb45
commit 538865f62a
No known key found for this signature in database
GPG Key ID: F6D9E9BF14C7D103
3 changed files with 8 additions and 10 deletions

View File

@ -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)
@ -1129,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
@ -1248,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
]))) { ]))) {
@ -1262,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;

View File

@ -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',

View File

@ -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,