1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-25 05:23:13 +03:00

Throw error if missing userId in CryptoApi.findVerificationRequestDMInProgress (#3641)

This commit is contained in:
Florian Duros
2023-08-01 14:20:01 +02:00
committed by GitHub
parent 5a782b7377
commit 2e9b34e0c3
2 changed files with 5 additions and 4 deletions

View File

@@ -578,9 +578,11 @@ describe("RustCrypto", () => {
}); });
describe("findVerificationRequestDMInProgress", () => { 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(); const rustCrypto = await makeTestRustCrypto();
expect(rustCrypto.findVerificationRequestDMInProgress(testData.TEST_ROOM_ID)).not.toBeDefined(); expect(() => rustCrypto.findVerificationRequestDMInProgress(testData.TEST_ROOM_ID)).toThrow(
"missing userId",
);
}); });
}); });
}); });

View File

@@ -686,8 +686,7 @@ export class RustCrypto extends TypedEventEmitter<RustCryptoEvents, RustCryptoEv
* *
*/ */
public findVerificationRequestDMInProgress(roomId: string, userId?: string): VerificationRequest | undefined { public findVerificationRequestDMInProgress(roomId: string, userId?: string): VerificationRequest | undefined {
// TODO raise an error if (!userId) throw new Error("missing userId");
if (!userId) return;
const requests: RustSdkCryptoJs.VerificationRequest[] = this.olmMachine.getVerificationRequests( const requests: RustSdkCryptoJs.VerificationRequest[] = this.olmMachine.getVerificationRequests(
new RustSdkCryptoJs.UserId(userId), new RustSdkCryptoJs.UserId(userId),