Skip to content

Commit

Permalink
Use stable calls to /room_keys (#2729)
Browse files Browse the repository at this point in the history
* Use stable calls to `/room_keys`

Fixes element-hq/element-web#22839

* Appease the CI
  • Loading branch information
turt2live authored Oct 4, 2022
1 parent 2f24e90 commit b1ed972
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2700,7 +2700,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
try {
res = await this.http.authedRequest<IKeyBackupInfo>(
undefined, Method.Get, "/room_keys/version", undefined, undefined,
{ prefix: PREFIX_UNSTABLE },
{ prefix: PREFIX_V3 },
);
} catch (e) {
if (e.errcode === 'M_NOT_FOUND') {
Expand Down Expand Up @@ -2856,7 +2856,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa

const res = await this.http.authedRequest<IKeyBackupInfo>(
undefined, Method.Post, "/room_keys/version", undefined, data,
{ prefix: PREFIX_UNSTABLE },
{ prefix: PREFIX_V3 },
);

// We could assume everything's okay and enable directly, but this ensures
Expand Down Expand Up @@ -2888,7 +2888,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa

return this.http.authedRequest(
undefined, Method.Delete, path, undefined, undefined,
{ prefix: PREFIX_UNSTABLE },
{ prefix: PREFIX_V3 },
);
}

Expand Down
6 changes: 3 additions & 3 deletions src/crypto/EncryptionSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { logger } from "../logger";
import { MatrixEvent } from "../models/event";
import { createCryptoStoreCacheCallbacks, ICacheCallbacks } from "./CrossSigning";
import { IndexedDBCryptoStore } from './store/indexeddb-crypto-store';
import { Method, PREFIX_UNSTABLE } from "../http-api";
import { Method, PREFIX_V3 } from "../http-api";
import { Crypto, IBootstrapCrossSigningOpts } from "./index";
import {
ClientEvent,
Expand Down Expand Up @@ -246,14 +246,14 @@ export class EncryptionSetupOperation {
algorithm: this.keyBackupInfo.algorithm,
auth_data: this.keyBackupInfo.auth_data,
},
{ prefix: PREFIX_UNSTABLE },
{ prefix: PREFIX_V3 },
);
} else {
// add new key backup
await baseApis.http.authedRequest(
undefined, Method.Post, "/room_keys/version",
undefined, this.keyBackupInfo,
{ prefix: PREFIX_UNSTABLE },
{ prefix: PREFIX_V3 },
);
}
}
Expand Down

0 comments on commit b1ed972

Please sign in to comment.