Skip to content
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

Implement getting verification cancellation info in Rust crypto #3947

Merged
merged 6 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions spec/integ/crypto/verification.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,8 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("verification (%s)", (backend: st
expect(toDeviceMessage.transaction_id).toEqual(transactionId);
expect(toDeviceMessage.code).toEqual("m.user");
expect(request.phase).toEqual(VerificationPhase.Cancelled);
expect(request.cancellationCode).toEqual("m.user");
expect(request.cancellingUserId).toEqual("@alice:localhost");
Comment on lines +747 to +748
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like there are quite a lot of codepaths here which we're not testing at all, but I won't insist for now :)

});

it("can cancel during the SAS phase", async () => {
Expand Down
16 changes: 14 additions & 2 deletions src/rust-crypto/verification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,12 @@ export class RustVerificationRequest
* this verification.
*/
public get cancellationCode(): string | null {
throw new Error("not implemented");
const cancelInfo = this.inner.cancelInfo;
if (cancelInfo) {
return cancelInfo.cancelCode();
} else {
return null;
}
uhoreg marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand All @@ -434,7 +439,14 @@ export class RustVerificationRequest
* Only defined when phase is Cancelled
*/
public get cancellingUserId(): string | undefined {
throw new Error("not implemented");
const cancelInfo = this.inner.cancelInfo;
if (!cancelInfo) {
return undefined;
} else if (cancelInfo.cancelledbyUs()) {
return this.olmMachine.userId.toString();
} else {
return this.inner.otherUserId.toString();
}
}
}

Expand Down