Skip to content

Commit

Permalink
Throw error if missing userId in `CryptoApi.findVerificationRequest…
Browse files Browse the repository at this point in the history
…DMInProgress` (#3641)
  • Loading branch information
florianduros authored Aug 1, 2023
1 parent 5a782b7 commit 2e9b34e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 4 additions & 2 deletions spec/unit/rust-crypto/rust-crypto.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -578,9 +578,11 @@ describe("RustCrypto", () => {
});

describe("findVerificationRequestDMInProgress", () => {
it("returns undefined if the userId is not provided", async () => {
it("throws an error if the userId is not provided", async () => {
const rustCrypto = await makeTestRustCrypto();
expect(rustCrypto.findVerificationRequestDMInProgress(testData.TEST_ROOM_ID)).not.toBeDefined();
expect(() => rustCrypto.findVerificationRequestDMInProgress(testData.TEST_ROOM_ID)).toThrow(
"missing userId",
);
});
});
});
Expand Down
3 changes: 1 addition & 2 deletions src/rust-crypto/rust-crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -686,8 +686,7 @@ export class RustCrypto extends TypedEventEmitter<RustCryptoEvents, RustCryptoEv
*
*/
public findVerificationRequestDMInProgress(roomId: string, userId?: string): VerificationRequest | undefined {
// TODO raise an error
if (!userId) return;
if (!userId) throw new Error("missing userId");

const requests: RustSdkCryptoJs.VerificationRequest[] = this.olmMachine.getVerificationRequests(
new RustSdkCryptoJs.UserId(userId),
Expand Down

0 comments on commit 2e9b34e

Please sign in to comment.