-
-
Notifications
You must be signed in to change notification settings - Fork 605
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ElementR: fix emoji verification stalling when both ends hit start at the same time #4004
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few questions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Co-authored-by: Richard van der Hoff <[email protected]>
This is ready to merge, but I'm taking this afternoon off, and I don't want to merge this and then run off right away, so I'll merge on Monday |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I didn't review the tests previously. Nothing important here -- generally they look great. Just a few suggestions for cleanups which you might like if you have the time and inclination.
} | ||
const crossSigningKeys = JSON.parse(uploadSigningKeysRequest.body); | ||
// note: the upload signatures request and upload signing keys requests | ||
// don't need to me marked as sent in the Olm machine |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// don't need to me marked as sent in the Olm machine | |
// don't need to be marked as sent in the Olm machine |
'{"one_time_key_counts":{"signed_curve25519":100}}', | ||
); | ||
const crossSigningSignatures = JSON.parse(uploadSignaturesRequest.body); | ||
if (crossSigningSignatures[userId] && crossSigningSignatures[userId][deviceId]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks like this should always be true? I'd be tempted to get rid of this condition.
Alternatively, a ? operator would simplify:
if (crossSigningSignatures[userId] && crossSigningSignatures[userId][deviceId]) { | |
if (crossSigningSignatures[userId]?.[deviceId]) { |
Doesn't matter though.
customHandler: | ||
| ((request: OutgoingRequest | RustSdkCryptoJs.UploadSigningKeysRequest) => Promise<any>) | ||
| undefined = undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider defining something like:
type CustomRequestHandler = ((request: OutgoingRequest | RustSdkCryptoJs.UploadSigningKeysRequest) => Promise<any>);
Also, ?
after a param is effectively the same as | undefined
, and = undefined
is the default.
customHandler: | |
| ((request: OutgoingRequest | RustSdkCryptoJs.UploadSigningKeysRequest) => Promise<any>) | |
| undefined = undefined, | |
customHandler?: CustomRequestHandler, |
async function makeOutgoingRequest( | ||
request: OutgoingRequest | RustSdkCryptoJs.UploadSigningKeysRequest, | ||
): Promise<any> { | ||
let resp: any = customHandler && (await customHandler(request)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let resp: any = customHandler && (await customHandler(request)); | |
let resp: any = await customHandler?.(request); |
I think?
const promise = (async () => { | ||
while (!stopRequestLoop) { | ||
const requests = await ourOlmMachine.outgoingRequests(); | ||
for (const request of requests) { | ||
await makeOutgoingRequest(request); | ||
} | ||
} | ||
})(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a bit hard to read.
const promise = (async () => { | |
while (!stopRequestLoop) { | |
const requests = await ourOlmMachine.outgoingRequests(); | |
for (const request of requests) { | |
await makeOutgoingRequest(request); | |
} | |
} | |
})(); | |
async function runLoop() { | |
while (!stopRequestLoop) { | |
const requests = await ourOlmMachine.outgoingRequests(); | |
for (const request of requests) { | |
await makeOutgoingRequest(request); | |
} | |
} | |
} | |
const loopCompletedPromise = runLoop(); |
request: OutgoingRequest | RustSdkCryptoJs.UploadSigningKeysRequest, | ||
): Promise<any> { | ||
let resp: any = customHandler && (await customHandler(request)); | ||
if (resp == undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (resp == undefined) { | |
if (resp === undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be quite nice to stick the whole body of this if
condition into a separate handleRequest(ourOlmMachine, theirOlmMachine)
function.
resp = { failures: {} }; | ||
} | ||
} | ||
if (!(request instanceof RustSdkCryptoJs.UploadSigningKeysRequest) && request.id) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can spell this more succinctly as
if (!(request instanceof RustSdkCryptoJs.UploadSigningKeysRequest) && request.id) { | |
if (request.id) { |
but maybe that upsets typescript?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, TypeScript gets upset about that
fixes element-hq/element-web#26723
When both ends hit "start", one of the sides will "win" and the other will "lose". The Rust crypto crate on the losing side replaces the SAS verifier with a new one. The current code does not detect this, and continues trying to use the old one. This PR switches the verifier to the new one when it changes.
Checklist
Here's what your changelog entry will look like:
🐛 Bug Fixes