Adds testing for fallback api
This commit is contained in:
parent
3b0a565822
commit
bc3b8d0a16
|
@ -21,6 +21,7 @@ internal object NetworkConstants {
|
||||||
private const val URI_API_PREFIX_PATH = "_matrix/client"
|
private const val URI_API_PREFIX_PATH = "_matrix/client"
|
||||||
const val URI_API_PREFIX_PATH_ = "$URI_API_PREFIX_PATH/"
|
const val URI_API_PREFIX_PATH_ = "$URI_API_PREFIX_PATH/"
|
||||||
const val URI_API_PREFIX_PATH_R0 = "$URI_API_PREFIX_PATH/r0/"
|
const val URI_API_PREFIX_PATH_R0 = "$URI_API_PREFIX_PATH/r0/"
|
||||||
|
const val URI_API_PREFIX_PATH_V1 = "${URI_API_PREFIX_PATH}v1/"
|
||||||
const val URI_API_PREFIX_PATH_UNSTABLE = "$URI_API_PREFIX_PATH/unstable/"
|
const val URI_API_PREFIX_PATH_UNSTABLE = "$URI_API_PREFIX_PATH/unstable/"
|
||||||
|
|
||||||
// Media
|
// Media
|
||||||
|
|
|
@ -19,6 +19,7 @@ package org.matrix.android.sdk.internal.session.space
|
||||||
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
||||||
import org.matrix.android.sdk.internal.network.executeRequest
|
import org.matrix.android.sdk.internal.network.executeRequest
|
||||||
import org.matrix.android.sdk.internal.task.Task
|
import org.matrix.android.sdk.internal.task.Task
|
||||||
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
internal interface ResolveSpaceInfoTask : Task<ResolveSpaceInfoTask.Params, SpacesResponse> {
|
internal interface ResolveSpaceInfoTask : Task<ResolveSpaceInfoTask.Params, SpacesResponse> {
|
||||||
|
@ -38,6 +39,10 @@ internal class DefaultResolveSpaceInfoTask @Inject constructor(
|
||||||
) : ResolveSpaceInfoTask {
|
) : ResolveSpaceInfoTask {
|
||||||
override suspend fun execute(params: ResolveSpaceInfoTask.Params): SpacesResponse {
|
override suspend fun execute(params: ResolveSpaceInfoTask.Params): SpacesResponse {
|
||||||
return executeRequest(globalErrorReceiver) {
|
return executeRequest(globalErrorReceiver) {
|
||||||
|
try {
|
||||||
|
throw RuntimeException("Test space task exception")
|
||||||
|
} catch (e: Throwable) {
|
||||||
|
Timber.i("Test fall back api")
|
||||||
spaceApi.getSpaceHierarchy(
|
spaceApi.getSpaceHierarchy(
|
||||||
spaceId = params.spaceId,
|
spaceId = params.spaceId,
|
||||||
suggestedOnly = params.suggestedOnly,
|
suggestedOnly = params.suggestedOnly,
|
||||||
|
@ -47,3 +52,4 @@ internal class DefaultResolveSpaceInfoTask @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -31,11 +31,22 @@ internal interface SpaceApi {
|
||||||
* @param from: Optional. Pagination token given to retrieve the next set of rooms.
|
* @param from: Optional. Pagination token given to retrieve the next set of rooms.
|
||||||
* Note that if a pagination token is provided, then the parameters given for suggested_only and max_depth must be the same.
|
* Note that if a pagination token is provided, then the parameters given for suggested_only and max_depth must be the same.
|
||||||
*/
|
*/
|
||||||
@GET(NetworkConstants.URI_API_PREFIX_PATH_ + "rooms/{roomID}/hierarchy")
|
@GET(NetworkConstants.URI_API_PREFIX_PATH_V1 + "rooms/{roomID}/hierarchy")
|
||||||
suspend fun getSpaceHierarchy(
|
suspend fun getSpaceHierarchy(
|
||||||
@Path("roomId") spaceId: String,
|
@Path("roomId") spaceId: String,
|
||||||
@Query("suggested_only") suggestedOnly: Boolean?,
|
@Query("suggested_only") suggestedOnly: Boolean?,
|
||||||
@Query("limit") limit: Int?,
|
@Query("limit") limit: Int?,
|
||||||
@Query("max_depth") maxDepth: Int?,
|
@Query("max_depth") maxDepth: Int?,
|
||||||
@Query("from") from: String?): SpacesResponse
|
@Query("from") from: String?): SpacesResponse
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unstable version of [getSpaceHierarchy]
|
||||||
|
*/
|
||||||
|
@GET(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "org.matrix.msc2946/rooms/{roomId}/hierarchy")
|
||||||
|
suspend fun getSpaceHierarchyUnstable(
|
||||||
|
@Path("roomId") spaceId: String,
|
||||||
|
@Query("suggested_only") suggestedOnly: Boolean?,
|
||||||
|
@Query("limit") limit: Int?,
|
||||||
|
@Query("max_depth") maxDepth: Int?,
|
||||||
|
@Query("from") from: String?): SpacesResponse
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue