@@ -50,6 +50,7 @@ import {
50
50
PREFIX_IDENTITY_V2 ,
51
51
PREFIX_MEDIA_R0 ,
52
52
PREFIX_R0 ,
53
+ PREFIX_V1 ,
53
54
PREFIX_UNSTABLE ,
54
55
retryNetworkOperation ,
55
56
UploadContentResponseType ,
@@ -722,6 +723,11 @@ interface IRoomKeysResponse {
722
723
interface IRoomsKeysResponse {
723
724
rooms : Record < string , IRoomKeysResponse > ;
724
725
}
726
+
727
+ interface IRoomHierarchy {
728
+ rooms : IHierarchyRoom [ ] ;
729
+ next_batch ?: string ;
730
+ }
725
731
/* eslint-enable camelcase */
726
732
727
733
// We're using this constant for methods overloading and inspect whether a variable
@@ -8372,24 +8378,32 @@ export class MatrixClient extends EventEmitter {
8372
8378
maxDepth ?: number ,
8373
8379
suggestedOnly = false ,
8374
8380
fromToken ?: string ,
8375
- ) : Promise < {
8376
- rooms : IHierarchyRoom [ ] ;
8377
- next_batch ?: string ; // eslint-disable-line camelcase
8378
- } > {
8381
+ ) : Promise < IRoomHierarchy > {
8379
8382
const path = utils . encodeUri ( "/rooms/$roomId/hierarchy" , {
8380
8383
$roomId : roomId ,
8381
8384
} ) ;
8382
8385
8383
- return this . http . authedRequest < {
8384
- rooms : IHierarchyRoom [ ] ;
8385
- next_batch ?: string ; // eslint-disable-line camelcase
8386
- } > ( undefined , Method . Get , path , {
8386
+ return this . http . authedRequest < IRoomHierarchy > ( undefined , Method . Get , path , {
8387
8387
suggested_only : String ( suggestedOnly ) ,
8388
8388
max_depth : maxDepth ?. toString ( ) ,
8389
8389
from : fromToken ,
8390
8390
limit : limit ?. toString ( ) ,
8391
8391
} , undefined , {
8392
- prefix : "/_matrix/client/unstable/org.matrix.msc2946" ,
8392
+ prefix : PREFIX_V1 ,
8393
+ } ) . catch ( e => {
8394
+ if ( e . errcode === "M_UNRECOGNIZED" ) {
8395
+ // fall back to the development prefix
8396
+ return this . http . authedRequest < IRoomHierarchy > ( undefined , Method . Get , path , {
8397
+ suggested_only : String ( suggestedOnly ) ,
8398
+ max_depth : String ( maxDepth ) ,
8399
+ from : fromToken ,
8400
+ limit : String ( limit ) ,
8401
+ } , undefined , {
8402
+ prefix : "/_matrix/client/unstable/org.matrix.msc2946" ,
8403
+ } ) ;
8404
+ }
8405
+
8406
+ throw e ;
8393
8407
} ) . catch ( e => {
8394
8408
if ( e . errcode === "M_UNRECOGNIZED" ) {
8395
8409
// fall back to the older space summary API as it exposes the same data just in a different shape.
0 commit comments