You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-26 17:03:12 +03:00
Use v1 prefix for /hierarchy API, falling back to both previous variants (#2022)
This commit is contained in:
committed by
GitHub
parent
e4d3124e72
commit
6ac84a2465
@@ -50,6 +50,7 @@ import {
|
||||
PREFIX_IDENTITY_V2,
|
||||
PREFIX_MEDIA_R0,
|
||||
PREFIX_R0,
|
||||
PREFIX_V1,
|
||||
PREFIX_UNSTABLE,
|
||||
retryNetworkOperation,
|
||||
UploadContentResponseType,
|
||||
@@ -722,6 +723,11 @@ interface IRoomKeysResponse {
|
||||
interface IRoomsKeysResponse {
|
||||
rooms: Record<string, IRoomKeysResponse>;
|
||||
}
|
||||
|
||||
interface IRoomHierarchy {
|
||||
rooms: IHierarchyRoom[];
|
||||
next_batch?: string;
|
||||
}
|
||||
/* eslint-enable camelcase */
|
||||
|
||||
// We're using this constant for methods overloading and inspect whether a variable
|
||||
@@ -8372,24 +8378,32 @@ export class MatrixClient extends EventEmitter {
|
||||
maxDepth?: number,
|
||||
suggestedOnly = false,
|
||||
fromToken?: string,
|
||||
): Promise<{
|
||||
rooms: IHierarchyRoom[];
|
||||
next_batch?: string; // eslint-disable-line camelcase
|
||||
}> {
|
||||
): Promise<IRoomHierarchy> {
|
||||
const path = utils.encodeUri("/rooms/$roomId/hierarchy", {
|
||||
$roomId: roomId,
|
||||
});
|
||||
|
||||
return this.http.authedRequest<{
|
||||
rooms: IHierarchyRoom[];
|
||||
next_batch?: string; // eslint-disable-line camelcase
|
||||
}>(undefined, Method.Get, path, {
|
||||
return this.http.authedRequest<IRoomHierarchy>(undefined, Method.Get, path, {
|
||||
suggested_only: String(suggestedOnly),
|
||||
max_depth: maxDepth?.toString(),
|
||||
from: fromToken,
|
||||
limit: limit?.toString(),
|
||||
}, undefined, {
|
||||
prefix: "/_matrix/client/unstable/org.matrix.msc2946",
|
||||
prefix: PREFIX_V1,
|
||||
}).catch(e => {
|
||||
if (e.errcode === "M_UNRECOGNIZED") {
|
||||
// fall back to the development prefix
|
||||
return this.http.authedRequest<IRoomHierarchy>(undefined, Method.Get, path, {
|
||||
suggested_only: String(suggestedOnly),
|
||||
max_depth: String(maxDepth),
|
||||
from: fromToken,
|
||||
limit: String(limit),
|
||||
}, undefined, {
|
||||
prefix: "/_matrix/client/unstable/org.matrix.msc2946",
|
||||
});
|
||||
}
|
||||
|
||||
throw e;
|
||||
}).catch(e => {
|
||||
if (e.errcode === "M_UNRECOGNIZED") {
|
||||
// fall back to the older space summary API as it exposes the same data just in a different shape.
|
||||
|
||||
Reference in New Issue
Block a user