@@ -50,6 +50,7 @@ import {
5050 PREFIX_IDENTITY_V2 ,
5151 PREFIX_MEDIA_R0 ,
5252 PREFIX_R0 ,
53+ PREFIX_V1 ,
5354 PREFIX_UNSTABLE ,
5455 retryNetworkOperation ,
5556 UploadContentResponseType ,
@@ -722,6 +723,11 @@ interface IRoomKeysResponse {
722723interface IRoomsKeysResponse {
723724 rooms : Record < string , IRoomKeysResponse > ;
724725}
726+
727+ interface IRoomHierarchy {
728+ rooms : IHierarchyRoom [ ] ;
729+ next_batch ?: string ;
730+ }
725731/* eslint-enable camelcase */
726732
727733// We're using this constant for methods overloading and inspect whether a variable
@@ -8372,24 +8378,32 @@ export class MatrixClient extends EventEmitter {
83728378 maxDepth ?: number ,
83738379 suggestedOnly = false ,
83748380 fromToken ?: string ,
8375- ) : Promise < {
8376- rooms : IHierarchyRoom [ ] ;
8377- next_batch ?: string ; // eslint-disable-line camelcase
8378- } > {
8381+ ) : Promise < IRoomHierarchy > {
83798382 const path = utils . encodeUri ( "/rooms/$roomId/hierarchy" , {
83808383 $roomId : roomId ,
83818384 } ) ;
83828385
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 , {
83878387 suggested_only : String ( suggestedOnly ) ,
83888388 max_depth : maxDepth ?. toString ( ) ,
83898389 from : fromToken ,
83908390 limit : limit ?. toString ( ) ,
83918391 } , 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 ;
83938407 } ) . catch ( e => {
83948408 if ( e . errcode === "M_UNRECOGNIZED" ) {
83958409 // fall back to the older space summary API as it exposes the same data just in a different shape.
0 commit comments