mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-25 19:05:56 +03:00
Merge pull request #3097 from vector-im/feature/bma/retrofit_suspend
Migrate Retrofit interface to coroutine calls
This commit is contained in:
commit
f42d143679
150 changed files with 608 additions and 631 deletions
|
@ -36,6 +36,7 @@ Test:
|
||||||
|
|
||||||
Other changes:
|
Other changes:
|
||||||
- Add version details on the login screen, in debug or developer mode
|
- Add version details on the login screen, in debug or developer mode
|
||||||
|
- Migrate Retrofit interface to coroutine calls
|
||||||
|
|
||||||
Changes in Element 1.1.3 (2021-03-18)
|
Changes in Element 1.1.3 (2021-03-18)
|
||||||
===================================================
|
===================================================
|
||||||
|
|
|
@ -37,6 +37,18 @@ fun Throwable.shouldBeRetried(): Boolean {
|
||||||
|| (this is Failure.ServerError && error.code == MatrixError.M_LIMIT_EXCEEDED)
|
|| (this is Failure.ServerError && error.code == MatrixError.M_LIMIT_EXCEEDED)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the retry delay in case of rate limit exceeded error, adding 100 ms, of defaultValue otherwise
|
||||||
|
*/
|
||||||
|
fun Throwable.getRetryDelay(defaultValue: Long): Long {
|
||||||
|
return (this as? Failure.ServerError)
|
||||||
|
?.error
|
||||||
|
?.takeIf { it.code == MatrixError.M_LIMIT_EXCEEDED }
|
||||||
|
?.retryAfterMillis
|
||||||
|
?.plus(100L)
|
||||||
|
?: defaultValue
|
||||||
|
}
|
||||||
|
|
||||||
fun Throwable.isInvalidPassword(): Boolean {
|
fun Throwable.isInvalidPassword(): Boolean {
|
||||||
return this is Failure.ServerError
|
return this is Failure.ServerError
|
||||||
&& error.code == MatrixError.M_FORBIDDEN
|
&& error.code == MatrixError.M_FORBIDDEN
|
||||||
|
|
|
@ -29,7 +29,6 @@ import org.matrix.android.sdk.internal.auth.registration.SuccessResult
|
||||||
import org.matrix.android.sdk.internal.auth.registration.ValidationCodeBody
|
import org.matrix.android.sdk.internal.auth.registration.ValidationCodeBody
|
||||||
import org.matrix.android.sdk.internal.auth.version.Versions
|
import org.matrix.android.sdk.internal.auth.version.Versions
|
||||||
import org.matrix.android.sdk.internal.network.NetworkConstants
|
import org.matrix.android.sdk.internal.network.NetworkConstants
|
||||||
import retrofit2.Call
|
|
||||||
import retrofit2.http.Body
|
import retrofit2.http.Body
|
||||||
import retrofit2.http.GET
|
import retrofit2.http.GET
|
||||||
import retrofit2.http.Headers
|
import retrofit2.http.Headers
|
||||||
|
@ -45,26 +44,26 @@ internal interface AuthAPI {
|
||||||
* Get a Riot config file, using the name including the domain
|
* Get a Riot config file, using the name including the domain
|
||||||
*/
|
*/
|
||||||
@GET("config.{domain}.json")
|
@GET("config.{domain}.json")
|
||||||
fun getRiotConfigDomain(@Path("domain") domain: String): Call<RiotConfig>
|
suspend fun getRiotConfigDomain(@Path("domain") domain: String): RiotConfig
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a Riot config file
|
* Get a Riot config file
|
||||||
*/
|
*/
|
||||||
@GET("config.json")
|
@GET("config.json")
|
||||||
fun getRiotConfig(): Call<RiotConfig>
|
suspend fun getRiotConfig(): RiotConfig
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the version information of the homeserver
|
* Get the version information of the homeserver
|
||||||
*/
|
*/
|
||||||
@GET(NetworkConstants.URI_API_PREFIX_PATH_ + "versions")
|
@GET(NetworkConstants.URI_API_PREFIX_PATH_ + "versions")
|
||||||
fun versions(): Call<Versions>
|
suspend fun versions(): Versions
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register to the homeserver, or get error 401 with a RegistrationFlowResponse object if registration is incomplete
|
* Register to the homeserver, or get error 401 with a RegistrationFlowResponse object if registration is incomplete
|
||||||
* Ref: https://matrix.org/docs/spec/client_server/latest#account-registration-and-management
|
* Ref: https://matrix.org/docs/spec/client_server/latest#account-registration-and-management
|
||||||
*/
|
*/
|
||||||
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "register")
|
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "register")
|
||||||
fun register(@Body registrationParams: RegistrationParams): Call<Credentials>
|
suspend fun register(@Body registrationParams: RegistrationParams): Credentials
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add 3Pid during registration
|
* Add 3Pid during registration
|
||||||
|
@ -72,22 +71,22 @@ internal interface AuthAPI {
|
||||||
* https://github.com/matrix-org/matrix-doc/pull/2290
|
* https://github.com/matrix-org/matrix-doc/pull/2290
|
||||||
*/
|
*/
|
||||||
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "register/{threePid}/requestToken")
|
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "register/{threePid}/requestToken")
|
||||||
fun add3Pid(@Path("threePid") threePid: String,
|
suspend fun add3Pid(@Path("threePid") threePid: String,
|
||||||
@Body params: AddThreePidRegistrationParams): Call<AddThreePidRegistrationResponse>
|
@Body params: AddThreePidRegistrationParams): AddThreePidRegistrationResponse
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate 3pid
|
* Validate 3pid
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
fun validate3Pid(@Url url: String,
|
suspend fun validate3Pid(@Url url: String,
|
||||||
@Body params: ValidationCodeBody): Call<SuccessResult>
|
@Body params: ValidationCodeBody): SuccessResult
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the supported login flow
|
* Get the supported login flow
|
||||||
* Ref: https://matrix.org/docs/spec/client_server/latest#get-matrix-client-r0-login
|
* Ref: https://matrix.org/docs/spec/client_server/latest#get-matrix-client-r0-login
|
||||||
*/
|
*/
|
||||||
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "login")
|
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "login")
|
||||||
fun getLoginFlows(): Call<LoginFlowResponse>
|
suspend fun getLoginFlows(): LoginFlowResponse
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pass params to the server for the current login phase.
|
* Pass params to the server for the current login phase.
|
||||||
|
@ -97,22 +96,22 @@ internal interface AuthAPI {
|
||||||
*/
|
*/
|
||||||
@Headers("CONNECT_TIMEOUT:60000", "READ_TIMEOUT:60000", "WRITE_TIMEOUT:60000")
|
@Headers("CONNECT_TIMEOUT:60000", "READ_TIMEOUT:60000", "WRITE_TIMEOUT:60000")
|
||||||
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "login")
|
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "login")
|
||||||
fun login(@Body loginParams: PasswordLoginParams): Call<Credentials>
|
suspend fun login(@Body loginParams: PasswordLoginParams): Credentials
|
||||||
|
|
||||||
// Unfortunately we cannot use interface for @Body parameter, so I duplicate the method for the type TokenLoginParams
|
// Unfortunately we cannot use interface for @Body parameter, so I duplicate the method for the type TokenLoginParams
|
||||||
@Headers("CONNECT_TIMEOUT:60000", "READ_TIMEOUT:60000", "WRITE_TIMEOUT:60000")
|
@Headers("CONNECT_TIMEOUT:60000", "READ_TIMEOUT:60000", "WRITE_TIMEOUT:60000")
|
||||||
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "login")
|
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "login")
|
||||||
fun login(@Body loginParams: TokenLoginParams): Call<Credentials>
|
suspend fun login(@Body loginParams: TokenLoginParams): Credentials
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ask the homeserver to reset the password associated with the provided email.
|
* Ask the homeserver to reset the password associated with the provided email.
|
||||||
*/
|
*/
|
||||||
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "account/password/email/requestToken")
|
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "account/password/email/requestToken")
|
||||||
fun resetPassword(@Body params: AddThreePidRegistrationParams): Call<AddThreePidRegistrationResponse>
|
suspend fun resetPassword(@Body params: AddThreePidRegistrationParams): AddThreePidRegistrationResponse
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ask the homeserver to reset the password with the provided new password once the email is validated.
|
* Ask the homeserver to reset the password with the provided new password once the email is validated.
|
||||||
*/
|
*/
|
||||||
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "account/password")
|
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "account/password")
|
||||||
fun resetPasswordMailConfirmed(@Body params: ResetPasswordMailConfirmed): Call<Unit>
|
suspend fun resetPasswordMailConfirmed(@Body params: ResetPasswordMailConfirmed)
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,6 @@ import org.matrix.android.sdk.api.failure.Failure
|
||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
import org.matrix.android.sdk.api.util.appendParamToUrl
|
import org.matrix.android.sdk.api.util.appendParamToUrl
|
||||||
import org.matrix.android.sdk.internal.SessionManager
|
import org.matrix.android.sdk.internal.SessionManager
|
||||||
import org.matrix.android.sdk.internal.auth.data.LoginFlowResponse
|
|
||||||
import org.matrix.android.sdk.internal.auth.data.RiotConfig
|
import org.matrix.android.sdk.internal.auth.data.RiotConfig
|
||||||
import org.matrix.android.sdk.internal.auth.db.PendingSessionData
|
import org.matrix.android.sdk.internal.auth.db.PendingSessionData
|
||||||
import org.matrix.android.sdk.internal.auth.login.DefaultLoginWizard
|
import org.matrix.android.sdk.internal.auth.login.DefaultLoginWizard
|
||||||
|
@ -172,8 +171,8 @@ internal class DefaultAuthenticationService @Inject constructor(
|
||||||
|
|
||||||
// First check the homeserver version
|
// First check the homeserver version
|
||||||
return runCatching {
|
return runCatching {
|
||||||
executeRequest<Versions>(null) {
|
executeRequest(null) {
|
||||||
apiCall = authAPI.versions()
|
authAPI.versions()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.map { versions ->
|
.map { versions ->
|
||||||
|
@ -204,8 +203,8 @@ internal class DefaultAuthenticationService @Inject constructor(
|
||||||
|
|
||||||
// Ok, try to get the config.domain.json file of a RiotWeb client
|
// Ok, try to get the config.domain.json file of a RiotWeb client
|
||||||
return runCatching {
|
return runCatching {
|
||||||
executeRequest<RiotConfig>(null) {
|
executeRequest(null) {
|
||||||
apiCall = authAPI.getRiotConfigDomain(domain)
|
authAPI.getRiotConfigDomain(domain)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.map { riotConfig ->
|
.map { riotConfig ->
|
||||||
|
@ -232,8 +231,8 @@ internal class DefaultAuthenticationService @Inject constructor(
|
||||||
|
|
||||||
// Ok, try to get the config.json file of a RiotWeb client
|
// Ok, try to get the config.json file of a RiotWeb client
|
||||||
return runCatching {
|
return runCatching {
|
||||||
executeRequest<RiotConfig>(null) {
|
executeRequest(null) {
|
||||||
apiCall = authAPI.getRiotConfig()
|
authAPI.getRiotConfig()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.map { riotConfig ->
|
.map { riotConfig ->
|
||||||
|
@ -265,8 +264,8 @@ internal class DefaultAuthenticationService @Inject constructor(
|
||||||
|
|
||||||
val newAuthAPI = buildAuthAPI(newHomeServerConnectionConfig)
|
val newAuthAPI = buildAuthAPI(newHomeServerConnectionConfig)
|
||||||
|
|
||||||
val versions = executeRequest<Versions>(null) {
|
val versions = executeRequest(null) {
|
||||||
apiCall = newAuthAPI.versions()
|
newAuthAPI.versions()
|
||||||
}
|
}
|
||||||
|
|
||||||
return getLoginFlowResult(newAuthAPI, versions, defaultHomeServerUrl)
|
return getLoginFlowResult(newAuthAPI, versions, defaultHomeServerUrl)
|
||||||
|
@ -293,8 +292,8 @@ internal class DefaultAuthenticationService @Inject constructor(
|
||||||
|
|
||||||
val newAuthAPI = buildAuthAPI(newHomeServerConnectionConfig)
|
val newAuthAPI = buildAuthAPI(newHomeServerConnectionConfig)
|
||||||
|
|
||||||
val versions = executeRequest<Versions>(null) {
|
val versions = executeRequest(null) {
|
||||||
apiCall = newAuthAPI.versions()
|
newAuthAPI.versions()
|
||||||
}
|
}
|
||||||
|
|
||||||
getLoginFlowResult(newAuthAPI, versions, wellknownResult.homeServerUrl)
|
getLoginFlowResult(newAuthAPI, versions, wellknownResult.homeServerUrl)
|
||||||
|
@ -305,8 +304,8 @@ internal class DefaultAuthenticationService @Inject constructor(
|
||||||
|
|
||||||
private suspend fun getLoginFlowResult(authAPI: AuthAPI, versions: Versions, homeServerUrl: String): LoginFlowResult {
|
private suspend fun getLoginFlowResult(authAPI: AuthAPI, versions: Versions, homeServerUrl: String): LoginFlowResult {
|
||||||
// Get the login flow
|
// Get the login flow
|
||||||
val loginFlowResponse = executeRequest<LoginFlowResponse>(null) {
|
val loginFlowResponse = executeRequest(null) {
|
||||||
apiCall = authAPI.getLoginFlows()
|
authAPI.getLoginFlows()
|
||||||
}
|
}
|
||||||
return LoginFlowResult.Success(
|
return LoginFlowResult.Success(
|
||||||
loginFlowResponse.flows.orEmpty().mapNotNull { it.type },
|
loginFlowResponse.flows.orEmpty().mapNotNull { it.type },
|
||||||
|
|
|
@ -20,7 +20,6 @@ import dagger.Lazy
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
|
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
|
||||||
import org.matrix.android.sdk.api.failure.Failure
|
import org.matrix.android.sdk.api.failure.Failure
|
||||||
import org.matrix.android.sdk.internal.auth.data.LoginFlowResponse
|
|
||||||
import org.matrix.android.sdk.internal.di.Unauthenticated
|
import org.matrix.android.sdk.internal.di.Unauthenticated
|
||||||
import org.matrix.android.sdk.internal.network.RetrofitFactory
|
import org.matrix.android.sdk.internal.network.RetrofitFactory
|
||||||
import org.matrix.android.sdk.internal.network.executeRequest
|
import org.matrix.android.sdk.internal.network.executeRequest
|
||||||
|
@ -49,8 +48,8 @@ internal class DefaultIsValidClientServerApiTask @Inject constructor(
|
||||||
.create(AuthAPI::class.java)
|
.create(AuthAPI::class.java)
|
||||||
|
|
||||||
return try {
|
return try {
|
||||||
executeRequest<LoginFlowResponse>(null) {
|
executeRequest(null) {
|
||||||
apiCall = authAPI.getLoginFlows()
|
authAPI.getLoginFlows()
|
||||||
}
|
}
|
||||||
// We get a response, so the API is valid
|
// We get a response, so the API is valid
|
||||||
true
|
true
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
package org.matrix.android.sdk.internal.auth.login
|
package org.matrix.android.sdk.internal.auth.login
|
||||||
|
|
||||||
import android.util.Patterns
|
import android.util.Patterns
|
||||||
import org.matrix.android.sdk.api.auth.data.Credentials
|
|
||||||
import org.matrix.android.sdk.api.auth.login.LoginWizard
|
import org.matrix.android.sdk.api.auth.login.LoginWizard
|
||||||
import org.matrix.android.sdk.api.auth.registration.RegisterThreePid
|
import org.matrix.android.sdk.api.auth.registration.RegisterThreePid
|
||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
|
@ -29,7 +28,6 @@ import org.matrix.android.sdk.internal.auth.data.ThreePidMedium
|
||||||
import org.matrix.android.sdk.internal.auth.data.TokenLoginParams
|
import org.matrix.android.sdk.internal.auth.data.TokenLoginParams
|
||||||
import org.matrix.android.sdk.internal.auth.db.PendingSessionData
|
import org.matrix.android.sdk.internal.auth.db.PendingSessionData
|
||||||
import org.matrix.android.sdk.internal.auth.registration.AddThreePidRegistrationParams
|
import org.matrix.android.sdk.internal.auth.registration.AddThreePidRegistrationParams
|
||||||
import org.matrix.android.sdk.internal.auth.registration.AddThreePidRegistrationResponse
|
|
||||||
import org.matrix.android.sdk.internal.auth.registration.RegisterAddThreePidTask
|
import org.matrix.android.sdk.internal.auth.registration.RegisterAddThreePidTask
|
||||||
import org.matrix.android.sdk.internal.network.executeRequest
|
import org.matrix.android.sdk.internal.network.executeRequest
|
||||||
|
|
||||||
|
@ -49,8 +47,8 @@ internal class DefaultLoginWizard(
|
||||||
} else {
|
} else {
|
||||||
PasswordLoginParams.userIdentifier(login, password, deviceName)
|
PasswordLoginParams.userIdentifier(login, password, deviceName)
|
||||||
}
|
}
|
||||||
val credentials = executeRequest<Credentials>(null) {
|
val credentials = executeRequest(null) {
|
||||||
apiCall = authAPI.login(loginParams)
|
authAPI.login(loginParams)
|
||||||
}
|
}
|
||||||
|
|
||||||
return sessionCreator.createSession(credentials, pendingSessionData.homeServerConnectionConfig)
|
return sessionCreator.createSession(credentials, pendingSessionData.homeServerConnectionConfig)
|
||||||
|
@ -63,8 +61,8 @@ internal class DefaultLoginWizard(
|
||||||
val loginParams = TokenLoginParams(
|
val loginParams = TokenLoginParams(
|
||||||
token = loginToken
|
token = loginToken
|
||||||
)
|
)
|
||||||
val credentials = executeRequest<Credentials>(null) {
|
val credentials = executeRequest(null) {
|
||||||
apiCall = authAPI.login(loginParams)
|
authAPI.login(loginParams)
|
||||||
}
|
}
|
||||||
|
|
||||||
return sessionCreator.createSession(credentials, pendingSessionData.homeServerConnectionConfig)
|
return sessionCreator.createSession(credentials, pendingSessionData.homeServerConnectionConfig)
|
||||||
|
@ -80,8 +78,8 @@ internal class DefaultLoginWizard(
|
||||||
pendingSessionData = pendingSessionData.copy(sendAttempt = pendingSessionData.sendAttempt + 1)
|
pendingSessionData = pendingSessionData.copy(sendAttempt = pendingSessionData.sendAttempt + 1)
|
||||||
.also { pendingSessionStore.savePendingSessionData(it) }
|
.also { pendingSessionStore.savePendingSessionData(it) }
|
||||||
|
|
||||||
val result = executeRequest<AddThreePidRegistrationResponse>(null) {
|
val result = executeRequest(null) {
|
||||||
apiCall = authAPI.resetPassword(AddThreePidRegistrationParams.from(param))
|
authAPI.resetPassword(AddThreePidRegistrationParams.from(param))
|
||||||
}
|
}
|
||||||
|
|
||||||
pendingSessionData = pendingSessionData.copy(resetPasswordData = ResetPasswordData(newPassword, result))
|
pendingSessionData = pendingSessionData.copy(resetPasswordData = ResetPasswordData(newPassword, result))
|
||||||
|
@ -98,8 +96,8 @@ internal class DefaultLoginWizard(
|
||||||
safeResetPasswordData.newPassword
|
safeResetPasswordData.newPassword
|
||||||
)
|
)
|
||||||
|
|
||||||
executeRequest<Unit>(null) {
|
executeRequest(null) {
|
||||||
apiCall = authAPI.resetPasswordMailConfirmed(param)
|
authAPI.resetPasswordMailConfirmed(param)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set to null?
|
// Set to null?
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
package org.matrix.android.sdk.internal.auth.login
|
package org.matrix.android.sdk.internal.auth.login
|
||||||
|
|
||||||
import dagger.Lazy
|
import dagger.Lazy
|
||||||
import org.matrix.android.sdk.api.auth.data.Credentials
|
|
||||||
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
|
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
|
||||||
import org.matrix.android.sdk.api.failure.Failure
|
import org.matrix.android.sdk.api.failure.Failure
|
||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
|
@ -59,19 +58,16 @@ internal class DefaultDirectLoginTask @Inject constructor(
|
||||||
val loginParams = PasswordLoginParams.userIdentifier(params.userId, params.password, params.deviceName)
|
val loginParams = PasswordLoginParams.userIdentifier(params.userId, params.password, params.deviceName)
|
||||||
|
|
||||||
val credentials = try {
|
val credentials = try {
|
||||||
executeRequest<Credentials>(null) {
|
executeRequest(null) {
|
||||||
apiCall = authAPI.login(loginParams)
|
authAPI.login(loginParams)
|
||||||
}
|
}
|
||||||
} catch (throwable: Throwable) {
|
} catch (throwable: Throwable) {
|
||||||
when (throwable) {
|
throw when (throwable) {
|
||||||
is UnrecognizedCertificateException -> {
|
is UnrecognizedCertificateException -> Failure.UnrecognizedCertificateFailure(
|
||||||
throw Failure.UnrecognizedCertificateFailure(
|
homeServerUrl,
|
||||||
homeServerUrl,
|
throwable.fingerprint
|
||||||
throwable.fingerprint
|
)
|
||||||
)
|
else -> throwable
|
||||||
}
|
|
||||||
else ->
|
|
||||||
throw throwable
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ internal class DefaultRegisterAddThreePidTask(
|
||||||
|
|
||||||
override suspend fun execute(params: RegisterAddThreePidTask.Params): AddThreePidRegistrationResponse {
|
override suspend fun execute(params: RegisterAddThreePidTask.Params): AddThreePidRegistrationResponse {
|
||||||
return executeRequest(null) {
|
return executeRequest(null) {
|
||||||
apiCall = authAPI.add3Pid(params.threePid.toPath(), AddThreePidRegistrationParams.from(params))
|
authAPI.add3Pid(params.threePid.toPath(), AddThreePidRegistrationParams.from(params))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ internal class DefaultRegisterTask(
|
||||||
override suspend fun execute(params: RegisterTask.Params): Credentials {
|
override suspend fun execute(params: RegisterTask.Params): Credentials {
|
||||||
try {
|
try {
|
||||||
return executeRequest(null) {
|
return executeRequest(null) {
|
||||||
apiCall = authAPI.register(params.registrationParams)
|
authAPI.register(params.registrationParams)
|
||||||
}
|
}
|
||||||
} catch (throwable: Throwable) {
|
} catch (throwable: Throwable) {
|
||||||
throw throwable.toRegistrationFlowResponse()
|
throw throwable.toRegistrationFlowResponse()
|
||||||
|
|
|
@ -33,7 +33,7 @@ internal class DefaultValidateCodeTask(
|
||||||
|
|
||||||
override suspend fun execute(params: ValidateCodeTask.Params): SuccessResult {
|
override suspend fun execute(params: ValidateCodeTask.Params): SuccessResult {
|
||||||
return executeRequest(null) {
|
return executeRequest(null) {
|
||||||
apiCall = authAPI.validate3Pid(params.url, params.body)
|
authAPI.validate3Pid(params.url, params.body)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,6 @@ import org.matrix.android.sdk.internal.crypto.model.rest.SignatureUploadResponse
|
||||||
import org.matrix.android.sdk.internal.crypto.model.rest.UpdateDeviceInfoBody
|
import org.matrix.android.sdk.internal.crypto.model.rest.UpdateDeviceInfoBody
|
||||||
import org.matrix.android.sdk.internal.crypto.model.rest.UploadSigningKeysBody
|
import org.matrix.android.sdk.internal.crypto.model.rest.UploadSigningKeysBody
|
||||||
import org.matrix.android.sdk.internal.network.NetworkConstants
|
import org.matrix.android.sdk.internal.network.NetworkConstants
|
||||||
import retrofit2.Call
|
|
||||||
import retrofit2.http.Body
|
import retrofit2.http.Body
|
||||||
import retrofit2.http.GET
|
import retrofit2.http.GET
|
||||||
import retrofit2.http.HTTP
|
import retrofit2.http.HTTP
|
||||||
|
@ -46,14 +45,14 @@ internal interface CryptoApi {
|
||||||
* Doc: https://matrix.org/docs/spec/client_server/latest#get-matrix-client-r0-devices
|
* Doc: https://matrix.org/docs/spec/client_server/latest#get-matrix-client-r0-devices
|
||||||
*/
|
*/
|
||||||
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "devices")
|
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "devices")
|
||||||
fun getDevices(): Call<DevicesListResponse>
|
suspend fun getDevices(): DevicesListResponse
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the device info by id
|
* Get the device info by id
|
||||||
* Doc: https://matrix.org/docs/spec/client_server/latest#get-matrix-client-r0-devices-deviceid
|
* Doc: https://matrix.org/docs/spec/client_server/latest#get-matrix-client-r0-devices-deviceid
|
||||||
*/
|
*/
|
||||||
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "devices/{deviceId}")
|
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "devices/{deviceId}")
|
||||||
fun getDeviceInfo(@Path("deviceId") deviceId: String): Call<DeviceInfo>
|
suspend fun getDeviceInfo(@Path("deviceId") deviceId: String): DeviceInfo
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Upload device and/or one-time keys.
|
* Upload device and/or one-time keys.
|
||||||
|
@ -62,7 +61,7 @@ internal interface CryptoApi {
|
||||||
* @param body the keys to be sent.
|
* @param body the keys to be sent.
|
||||||
*/
|
*/
|
||||||
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "keys/upload")
|
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "keys/upload")
|
||||||
fun uploadKeys(@Body body: KeysUploadBody): Call<KeysUploadResponse>
|
suspend fun uploadKeys(@Body body: KeysUploadBody): KeysUploadResponse
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Download device keys.
|
* Download device keys.
|
||||||
|
@ -71,7 +70,7 @@ internal interface CryptoApi {
|
||||||
* @param params the params.
|
* @param params the params.
|
||||||
*/
|
*/
|
||||||
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "keys/query")
|
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "keys/query")
|
||||||
fun downloadKeysForUsers(@Body params: KeysQueryBody): Call<KeysQueryResponse>
|
suspend fun downloadKeysForUsers(@Body params: KeysQueryBody): KeysQueryResponse
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CrossSigning - Uploading signing keys
|
* CrossSigning - Uploading signing keys
|
||||||
|
@ -79,7 +78,7 @@ internal interface CryptoApi {
|
||||||
* This endpoint requires UI Auth.
|
* This endpoint requires UI Auth.
|
||||||
*/
|
*/
|
||||||
@POST(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "keys/device_signing/upload")
|
@POST(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "keys/device_signing/upload")
|
||||||
fun uploadSigningKeys(@Body params: UploadSigningKeysBody): Call<KeysQueryResponse>
|
suspend fun uploadSigningKeys(@Body params: UploadSigningKeysBody): KeysQueryResponse
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CrossSigning - Uploading signatures
|
* CrossSigning - Uploading signatures
|
||||||
|
@ -98,7 +97,7 @@ internal interface CryptoApi {
|
||||||
* However, signatures made for other users' keys, made by her user-signing key, will not be included.
|
* However, signatures made for other users' keys, made by her user-signing key, will not be included.
|
||||||
*/
|
*/
|
||||||
@POST(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "keys/signatures/upload")
|
@POST(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "keys/signatures/upload")
|
||||||
fun uploadSignatures(@Body params: Map<String, @JvmSuppressWildcards Any>?): Call<SignatureUploadResponse>
|
suspend fun uploadSignatures(@Body params: Map<String, @JvmSuppressWildcards Any>?): SignatureUploadResponse
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Claim one-time keys.
|
* Claim one-time keys.
|
||||||
|
@ -107,7 +106,7 @@ internal interface CryptoApi {
|
||||||
* @param params the params.
|
* @param params the params.
|
||||||
*/
|
*/
|
||||||
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "keys/claim")
|
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "keys/claim")
|
||||||
fun claimOneTimeKeysForUsersDevices(@Body body: KeysClaimBody): Call<KeysClaimResponse>
|
suspend fun claimOneTimeKeysForUsersDevices(@Body body: KeysClaimBody): KeysClaimResponse
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send an event to a specific list of devices
|
* Send an event to a specific list of devices
|
||||||
|
@ -118,9 +117,9 @@ internal interface CryptoApi {
|
||||||
* @param body the body
|
* @param body the body
|
||||||
*/
|
*/
|
||||||
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "sendToDevice/{eventType}/{txnId}")
|
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "sendToDevice/{eventType}/{txnId}")
|
||||||
fun sendToDevice(@Path("eventType") eventType: String,
|
suspend fun sendToDevice(@Path("eventType") eventType: String,
|
||||||
@Path("txnId") transactionId: String,
|
@Path("txnId") transactionId: String,
|
||||||
@Body body: SendToDeviceBody): Call<Unit>
|
@Body body: SendToDeviceBody)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a device.
|
* Delete a device.
|
||||||
|
@ -130,8 +129,8 @@ internal interface CryptoApi {
|
||||||
* @param params the deletion parameters
|
* @param params the deletion parameters
|
||||||
*/
|
*/
|
||||||
@HTTP(path = NetworkConstants.URI_API_PREFIX_PATH_R0 + "devices/{device_id}", method = "DELETE", hasBody = true)
|
@HTTP(path = NetworkConstants.URI_API_PREFIX_PATH_R0 + "devices/{device_id}", method = "DELETE", hasBody = true)
|
||||||
fun deleteDevice(@Path("device_id") deviceId: String,
|
suspend fun deleteDevice(@Path("device_id") deviceId: String,
|
||||||
@Body params: DeleteDeviceParams): Call<Unit>
|
@Body params: DeleteDeviceParams)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the device information.
|
* Update the device information.
|
||||||
|
@ -141,8 +140,8 @@ internal interface CryptoApi {
|
||||||
* @param params the params
|
* @param params the params
|
||||||
*/
|
*/
|
||||||
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "devices/{device_id}")
|
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "devices/{device_id}")
|
||||||
fun updateDeviceInfo(@Path("device_id") deviceId: String,
|
suspend fun updateDeviceInfo(@Path("device_id") deviceId: String,
|
||||||
@Body params: UpdateDeviceInfoBody): Call<Unit>
|
@Body params: UpdateDeviceInfoBody)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the update devices list from two sync token.
|
* Get the update devices list from two sync token.
|
||||||
|
@ -152,6 +151,6 @@ internal interface CryptoApi {
|
||||||
* @param newToken the up-to token.
|
* @param newToken the up-to token.
|
||||||
*/
|
*/
|
||||||
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "keys/changes")
|
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "keys/changes")
|
||||||
fun getKeyChanges(@Query("from") oldToken: String,
|
suspend fun getKeyChanges(@Query("from") oldToken: String,
|
||||||
@Query("to") newToken: String): Call<KeyChangesResponse>
|
@Query("to") newToken: String): KeyChangesResponse
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,6 @@ import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.KeysVersionR
|
||||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.RoomKeysBackupData
|
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.RoomKeysBackupData
|
||||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.UpdateKeysBackupVersionBody
|
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.UpdateKeysBackupVersionBody
|
||||||
import org.matrix.android.sdk.internal.network.NetworkConstants
|
import org.matrix.android.sdk.internal.network.NetworkConstants
|
||||||
import retrofit2.Call
|
|
||||||
import retrofit2.http.Body
|
import retrofit2.http.Body
|
||||||
import retrofit2.http.DELETE
|
import retrofit2.http.DELETE
|
||||||
import retrofit2.http.GET
|
import retrofit2.http.GET
|
||||||
|
@ -48,14 +47,14 @@ internal interface RoomKeysApi {
|
||||||
* @param createKeysBackupVersionBody the body
|
* @param createKeysBackupVersionBody the body
|
||||||
*/
|
*/
|
||||||
@POST(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/version")
|
@POST(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/version")
|
||||||
fun createKeysBackupVersion(@Body createKeysBackupVersionBody: CreateKeysBackupVersionBody): Call<KeysVersion>
|
suspend fun createKeysBackupVersion(@Body createKeysBackupVersionBody: CreateKeysBackupVersionBody): KeysVersion
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the key backup last version
|
* Get the key backup last version
|
||||||
* If not supported by the server, an error is returned: {"errcode":"M_NOT_FOUND","error":"No backup found"}
|
* If not supported by the server, an error is returned: {"errcode":"M_NOT_FOUND","error":"No backup found"}
|
||||||
*/
|
*/
|
||||||
@GET(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/version")
|
@GET(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/version")
|
||||||
fun getKeysBackupLastVersion(): Call<KeysVersionResult>
|
suspend fun getKeysBackupLastVersion(): KeysVersionResult
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get information about the given version.
|
* Get information about the given version.
|
||||||
|
@ -64,7 +63,7 @@ internal interface RoomKeysApi {
|
||||||
* @param version version
|
* @param version version
|
||||||
*/
|
*/
|
||||||
@GET(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/version/{version}")
|
@GET(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/version/{version}")
|
||||||
fun getKeysBackupVersion(@Path("version") version: String): Call<KeysVersionResult>
|
suspend fun getKeysBackupVersion(@Path("version") version: String): KeysVersionResult
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update information about the given version.
|
* Update information about the given version.
|
||||||
|
@ -72,8 +71,8 @@ internal interface RoomKeysApi {
|
||||||
* @param updateKeysBackupVersionBody the body
|
* @param updateKeysBackupVersionBody the body
|
||||||
*/
|
*/
|
||||||
@PUT(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/version/{version}")
|
@PUT(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/version/{version}")
|
||||||
fun updateKeysBackupVersion(@Path("version") version: String,
|
suspend fun updateKeysBackupVersion(@Path("version") version: String,
|
||||||
@Body keysBackupVersionBody: UpdateKeysBackupVersionBody): Call<Unit>
|
@Body keysBackupVersionBody: UpdateKeysBackupVersionBody)
|
||||||
|
|
||||||
/* ==========================================================================================
|
/* ==========================================================================================
|
||||||
* Storing keys
|
* Storing keys
|
||||||
|
@ -94,10 +93,10 @@ internal interface RoomKeysApi {
|
||||||
* @param keyBackupData the data to send
|
* @param keyBackupData the data to send
|
||||||
*/
|
*/
|
||||||
@PUT(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/keys/{roomId}/{sessionId}")
|
@PUT(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/keys/{roomId}/{sessionId}")
|
||||||
fun storeRoomSessionData(@Path("roomId") roomId: String,
|
suspend fun storeRoomSessionData(@Path("roomId") roomId: String,
|
||||||
@Path("sessionId") sessionId: String,
|
@Path("sessionId") sessionId: String,
|
||||||
@Query("version") version: String,
|
@Query("version") version: String,
|
||||||
@Body keyBackupData: KeyBackupData): Call<BackupKeysResult>
|
@Body keyBackupData: KeyBackupData): BackupKeysResult
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store several keys for the given room, using the given backup version.
|
* Store several keys for the given room, using the given backup version.
|
||||||
|
@ -107,9 +106,9 @@ internal interface RoomKeysApi {
|
||||||
* @param roomKeysBackupData the data to send
|
* @param roomKeysBackupData the data to send
|
||||||
*/
|
*/
|
||||||
@PUT(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/keys/{roomId}")
|
@PUT(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/keys/{roomId}")
|
||||||
fun storeRoomSessionsData(@Path("roomId") roomId: String,
|
suspend fun storeRoomSessionsData(@Path("roomId") roomId: String,
|
||||||
@Query("version") version: String,
|
@Query("version") version: String,
|
||||||
@Body roomKeysBackupData: RoomKeysBackupData): Call<BackupKeysResult>
|
@Body roomKeysBackupData: RoomKeysBackupData): BackupKeysResult
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store several keys, using the given backup version.
|
* Store several keys, using the given backup version.
|
||||||
|
@ -118,8 +117,8 @@ internal interface RoomKeysApi {
|
||||||
* @param keysBackupData the data to send
|
* @param keysBackupData the data to send
|
||||||
*/
|
*/
|
||||||
@PUT(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/keys")
|
@PUT(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/keys")
|
||||||
fun storeSessionsData(@Query("version") version: String,
|
suspend fun storeSessionsData(@Query("version") version: String,
|
||||||
@Body keysBackupData: KeysBackupData): Call<BackupKeysResult>
|
@Body keysBackupData: KeysBackupData): BackupKeysResult
|
||||||
|
|
||||||
/* ==========================================================================================
|
/* ==========================================================================================
|
||||||
* Retrieving keys
|
* Retrieving keys
|
||||||
|
@ -133,9 +132,9 @@ internal interface RoomKeysApi {
|
||||||
* @param version the version of the backup, or empty String to retrieve the last version
|
* @param version the version of the backup, or empty String to retrieve the last version
|
||||||
*/
|
*/
|
||||||
@GET(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/keys/{roomId}/{sessionId}")
|
@GET(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/keys/{roomId}/{sessionId}")
|
||||||
fun getRoomSessionData(@Path("roomId") roomId: String,
|
suspend fun getRoomSessionData(@Path("roomId") roomId: String,
|
||||||
@Path("sessionId") sessionId: String,
|
@Path("sessionId") sessionId: String,
|
||||||
@Query("version") version: String): Call<KeyBackupData>
|
@Query("version") version: String): KeyBackupData
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve all the keys for the given room from the backup.
|
* Retrieve all the keys for the given room from the backup.
|
||||||
|
@ -144,8 +143,8 @@ internal interface RoomKeysApi {
|
||||||
* @param version the version of the backup, or empty String to retrieve the last version
|
* @param version the version of the backup, or empty String to retrieve the last version
|
||||||
*/
|
*/
|
||||||
@GET(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/keys/{roomId}")
|
@GET(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/keys/{roomId}")
|
||||||
fun getRoomSessionsData(@Path("roomId") roomId: String,
|
suspend fun getRoomSessionsData(@Path("roomId") roomId: String,
|
||||||
@Query("version") version: String): Call<RoomKeysBackupData>
|
@Query("version") version: String): RoomKeysBackupData
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve all the keys from the backup.
|
* Retrieve all the keys from the backup.
|
||||||
|
@ -153,7 +152,7 @@ internal interface RoomKeysApi {
|
||||||
* @param version the version of the backup, or empty String to retrieve the last version
|
* @param version the version of the backup, or empty String to retrieve the last version
|
||||||
*/
|
*/
|
||||||
@GET(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/keys")
|
@GET(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/keys")
|
||||||
fun getSessionsData(@Query("version") version: String): Call<KeysBackupData>
|
suspend fun getSessionsData(@Query("version") version: String): KeysBackupData
|
||||||
|
|
||||||
/* ==========================================================================================
|
/* ==========================================================================================
|
||||||
* Deleting keys
|
* Deleting keys
|
||||||
|
@ -163,22 +162,22 @@ internal interface RoomKeysApi {
|
||||||
* Deletes keys from the backup.
|
* Deletes keys from the backup.
|
||||||
*/
|
*/
|
||||||
@DELETE(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/keys/{roomId}/{sessionId}")
|
@DELETE(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/keys/{roomId}/{sessionId}")
|
||||||
fun deleteRoomSessionData(@Path("roomId") roomId: String,
|
suspend fun deleteRoomSessionData(@Path("roomId") roomId: String,
|
||||||
@Path("sessionId") sessionId: String,
|
@Path("sessionId") sessionId: String,
|
||||||
@Query("version") version: String): Call<Unit>
|
@Query("version") version: String)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes keys from the backup.
|
* Deletes keys from the backup.
|
||||||
*/
|
*/
|
||||||
@DELETE(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/keys/{roomId}")
|
@DELETE(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/keys/{roomId}")
|
||||||
fun deleteRoomSessionsData(@Path("roomId") roomId: String,
|
suspend fun deleteRoomSessionsData(@Path("roomId") roomId: String,
|
||||||
@Query("version") version: String): Call<Unit>
|
@Query("version") version: String)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes keys from the backup.
|
* Deletes keys from the backup.
|
||||||
*/
|
*/
|
||||||
@DELETE(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/keys")
|
@DELETE(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/keys")
|
||||||
fun deleteSessionsData(@Query("version") version: String): Call<Unit>
|
suspend fun deleteSessionsData(@Query("version") version: String)
|
||||||
|
|
||||||
/* ==========================================================================================
|
/* ==========================================================================================
|
||||||
* Deleting backup
|
* Deleting backup
|
||||||
|
@ -188,5 +187,5 @@ internal interface RoomKeysApi {
|
||||||
* Deletes a backup.
|
* Deletes a backup.
|
||||||
*/
|
*/
|
||||||
@DELETE(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/version/{version}")
|
@DELETE(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/version/{version}")
|
||||||
fun deleteBackup(@Path("version") version: String): Call<Unit>
|
suspend fun deleteBackup(@Path("version") version: String)
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ internal class DefaultCreateKeysBackupVersionTask @Inject constructor(
|
||||||
|
|
||||||
override suspend fun execute(params: CreateKeysBackupVersionBody): KeysVersion {
|
override suspend fun execute(params: CreateKeysBackupVersionBody): KeysVersion {
|
||||||
return executeRequest(globalErrorReceiver) {
|
return executeRequest(globalErrorReceiver) {
|
||||||
apiCall = roomKeysApi.createKeysBackupVersion(params)
|
roomKeysApi.createKeysBackupVersion(params)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ internal class DefaultDeleteBackupTask @Inject constructor(
|
||||||
|
|
||||||
override suspend fun execute(params: DeleteBackupTask.Params) {
|
override suspend fun execute(params: DeleteBackupTask.Params) {
|
||||||
return executeRequest(globalErrorReceiver) {
|
return executeRequest(globalErrorReceiver) {
|
||||||
apiCall = roomKeysApi.deleteBackup(params.version)
|
roomKeysApi.deleteBackup(params.version)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ internal class DefaultDeleteRoomSessionDataTask @Inject constructor(
|
||||||
|
|
||||||
override suspend fun execute(params: DeleteRoomSessionDataTask.Params) {
|
override suspend fun execute(params: DeleteRoomSessionDataTask.Params) {
|
||||||
return executeRequest(globalErrorReceiver) {
|
return executeRequest(globalErrorReceiver) {
|
||||||
apiCall = roomKeysApi.deleteRoomSessionData(
|
roomKeysApi.deleteRoomSessionData(
|
||||||
params.roomId,
|
params.roomId,
|
||||||
params.sessionId,
|
params.sessionId,
|
||||||
params.version)
|
params.version)
|
||||||
|
|
|
@ -36,7 +36,7 @@ internal class DefaultDeleteRoomSessionsDataTask @Inject constructor(
|
||||||
|
|
||||||
override suspend fun execute(params: DeleteRoomSessionsDataTask.Params) {
|
override suspend fun execute(params: DeleteRoomSessionsDataTask.Params) {
|
||||||
return executeRequest(globalErrorReceiver) {
|
return executeRequest(globalErrorReceiver) {
|
||||||
apiCall = roomKeysApi.deleteRoomSessionsData(
|
roomKeysApi.deleteRoomSessionsData(
|
||||||
params.roomId,
|
params.roomId,
|
||||||
params.version)
|
params.version)
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ internal class DefaultDeleteSessionsDataTask @Inject constructor(
|
||||||
|
|
||||||
override suspend fun execute(params: DeleteSessionsDataTask.Params) {
|
override suspend fun execute(params: DeleteSessionsDataTask.Params) {
|
||||||
return executeRequest(globalErrorReceiver) {
|
return executeRequest(globalErrorReceiver) {
|
||||||
apiCall = roomKeysApi.deleteSessionsData(params.version)
|
roomKeysApi.deleteSessionsData(params.version)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ internal class DefaultGetKeysBackupLastVersionTask @Inject constructor(
|
||||||
|
|
||||||
override suspend fun execute(params: Unit): KeysVersionResult {
|
override suspend fun execute(params: Unit): KeysVersionResult {
|
||||||
return executeRequest(globalErrorReceiver) {
|
return executeRequest(globalErrorReceiver) {
|
||||||
apiCall = roomKeysApi.getKeysBackupLastVersion()
|
roomKeysApi.getKeysBackupLastVersion()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ internal class DefaultGetKeysBackupVersionTask @Inject constructor(
|
||||||
|
|
||||||
override suspend fun execute(params: String): KeysVersionResult {
|
override suspend fun execute(params: String): KeysVersionResult {
|
||||||
return executeRequest(globalErrorReceiver) {
|
return executeRequest(globalErrorReceiver) {
|
||||||
apiCall = roomKeysApi.getKeysBackupVersion(params)
|
roomKeysApi.getKeysBackupVersion(params)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ internal class DefaultGetRoomSessionDataTask @Inject constructor(
|
||||||
|
|
||||||
override suspend fun execute(params: GetRoomSessionDataTask.Params): KeyBackupData {
|
override suspend fun execute(params: GetRoomSessionDataTask.Params): KeyBackupData {
|
||||||
return executeRequest(globalErrorReceiver) {
|
return executeRequest(globalErrorReceiver) {
|
||||||
apiCall = roomKeysApi.getRoomSessionData(
|
roomKeysApi.getRoomSessionData(
|
||||||
params.roomId,
|
params.roomId,
|
||||||
params.sessionId,
|
params.sessionId,
|
||||||
params.version)
|
params.version)
|
||||||
|
|
|
@ -37,7 +37,7 @@ internal class DefaultGetRoomSessionsDataTask @Inject constructor(
|
||||||
|
|
||||||
override suspend fun execute(params: GetRoomSessionsDataTask.Params): RoomKeysBackupData {
|
override suspend fun execute(params: GetRoomSessionsDataTask.Params): RoomKeysBackupData {
|
||||||
return executeRequest(globalErrorReceiver) {
|
return executeRequest(globalErrorReceiver) {
|
||||||
apiCall = roomKeysApi.getRoomSessionsData(
|
roomKeysApi.getRoomSessionsData(
|
||||||
params.roomId,
|
params.roomId,
|
||||||
params.version)
|
params.version)
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ internal class DefaultGetSessionsDataTask @Inject constructor(
|
||||||
|
|
||||||
override suspend fun execute(params: GetSessionsDataTask.Params): KeysBackupData {
|
override suspend fun execute(params: GetSessionsDataTask.Params): KeysBackupData {
|
||||||
return executeRequest(globalErrorReceiver) {
|
return executeRequest(globalErrorReceiver) {
|
||||||
apiCall = roomKeysApi.getSessionsData(params.version)
|
roomKeysApi.getSessionsData(params.version)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ internal class DefaultStoreRoomSessionDataTask @Inject constructor(
|
||||||
|
|
||||||
override suspend fun execute(params: StoreRoomSessionDataTask.Params): BackupKeysResult {
|
override suspend fun execute(params: StoreRoomSessionDataTask.Params): BackupKeysResult {
|
||||||
return executeRequest(globalErrorReceiver) {
|
return executeRequest(globalErrorReceiver) {
|
||||||
apiCall = roomKeysApi.storeRoomSessionData(
|
roomKeysApi.storeRoomSessionData(
|
||||||
params.roomId,
|
params.roomId,
|
||||||
params.sessionId,
|
params.sessionId,
|
||||||
params.version,
|
params.version,
|
||||||
|
|
|
@ -39,7 +39,7 @@ internal class DefaultStoreRoomSessionsDataTask @Inject constructor(
|
||||||
|
|
||||||
override suspend fun execute(params: StoreRoomSessionsDataTask.Params): BackupKeysResult {
|
override suspend fun execute(params: StoreRoomSessionsDataTask.Params): BackupKeysResult {
|
||||||
return executeRequest(globalErrorReceiver) {
|
return executeRequest(globalErrorReceiver) {
|
||||||
apiCall = roomKeysApi.storeRoomSessionsData(
|
roomKeysApi.storeRoomSessionsData(
|
||||||
params.roomId,
|
params.roomId,
|
||||||
params.version,
|
params.version,
|
||||||
params.roomKeysBackupData)
|
params.roomKeysBackupData)
|
||||||
|
|
|
@ -38,7 +38,7 @@ internal class DefaultStoreSessionsDataTask @Inject constructor(
|
||||||
|
|
||||||
override suspend fun execute(params: StoreSessionsDataTask.Params): BackupKeysResult {
|
override suspend fun execute(params: StoreSessionsDataTask.Params): BackupKeysResult {
|
||||||
return executeRequest(globalErrorReceiver) {
|
return executeRequest(globalErrorReceiver) {
|
||||||
apiCall = roomKeysApi.storeSessionsData(
|
roomKeysApi.storeSessionsData(
|
||||||
params.version,
|
params.version,
|
||||||
params.keysBackupData)
|
params.keysBackupData)
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ internal class DefaultUpdateKeysBackupVersionTask @Inject constructor(
|
||||||
|
|
||||||
override suspend fun execute(params: UpdateKeysBackupVersionTask.Params) {
|
override suspend fun execute(params: UpdateKeysBackupVersionTask.Params) {
|
||||||
return executeRequest(globalErrorReceiver) {
|
return executeRequest(globalErrorReceiver) {
|
||||||
apiCall = roomKeysApi.updateKeysBackupVersion(params.version, params.keysBackupVersionBody)
|
roomKeysApi.updateKeysBackupVersion(params.version, params.keysBackupVersionBody)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ import org.matrix.android.sdk.internal.crypto.api.CryptoApi
|
||||||
import org.matrix.android.sdk.internal.crypto.model.MXKey
|
import org.matrix.android.sdk.internal.crypto.model.MXKey
|
||||||
import org.matrix.android.sdk.internal.crypto.model.MXUsersDevicesMap
|
import org.matrix.android.sdk.internal.crypto.model.MXUsersDevicesMap
|
||||||
import org.matrix.android.sdk.internal.crypto.model.rest.KeysClaimBody
|
import org.matrix.android.sdk.internal.crypto.model.rest.KeysClaimBody
|
||||||
import org.matrix.android.sdk.internal.crypto.model.rest.KeysClaimResponse
|
|
||||||
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
|
||||||
|
@ -42,8 +41,8 @@ internal class DefaultClaimOneTimeKeysForUsersDevice @Inject constructor(
|
||||||
override suspend fun execute(params: ClaimOneTimeKeysForUsersDeviceTask.Params): MXUsersDevicesMap<MXKey> {
|
override suspend fun execute(params: ClaimOneTimeKeysForUsersDeviceTask.Params): MXUsersDevicesMap<MXKey> {
|
||||||
val body = KeysClaimBody(oneTimeKeys = params.usersDevicesKeyTypesMap.map)
|
val body = KeysClaimBody(oneTimeKeys = params.usersDevicesKeyTypesMap.map)
|
||||||
|
|
||||||
val keysClaimResponse = executeRequest<KeysClaimResponse>(globalErrorReceiver) {
|
val keysClaimResponse = executeRequest(globalErrorReceiver) {
|
||||||
apiCall = cryptoApi.claimOneTimeKeysForUsersDevices(body)
|
cryptoApi.claimOneTimeKeysForUsersDevices(body)
|
||||||
}
|
}
|
||||||
val map = MXUsersDevicesMap<MXKey>()
|
val map = MXUsersDevicesMap<MXKey>()
|
||||||
keysClaimResponse.oneTimeKeys?.let { oneTimeKeys ->
|
keysClaimResponse.oneTimeKeys?.let { oneTimeKeys ->
|
||||||
|
|
|
@ -42,8 +42,8 @@ internal class DefaultDeleteDeviceTask @Inject constructor(
|
||||||
|
|
||||||
override suspend fun execute(params: DeleteDeviceTask.Params) {
|
override suspend fun execute(params: DeleteDeviceTask.Params) {
|
||||||
try {
|
try {
|
||||||
executeRequest<Unit>(globalErrorReceiver) {
|
executeRequest(globalErrorReceiver) {
|
||||||
apiCall = cryptoApi.deleteDevice(params.deviceId, DeleteDeviceParams(params.userAuthParam?.asMap()))
|
cryptoApi.deleteDevice(params.deviceId, DeleteDeviceParams(params.userAuthParam?.asMap()))
|
||||||
}
|
}
|
||||||
} catch (throwable: Throwable) {
|
} catch (throwable: Throwable) {
|
||||||
if (params.userInteractiveAuthInterceptor == null
|
if (params.userInteractiveAuthInterceptor == null
|
||||||
|
|
|
@ -72,8 +72,8 @@ internal class DefaultDownloadKeysForUsers @Inject constructor(
|
||||||
}
|
}
|
||||||
.map { body ->
|
.map { body ->
|
||||||
async {
|
async {
|
||||||
val result = executeRequest<KeysQueryResponse>(globalErrorReceiver) {
|
val result = executeRequest(globalErrorReceiver) {
|
||||||
apiCall = cryptoApi.downloadKeysForUsers(body)
|
cryptoApi.downloadKeysForUsers(body)
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex.withLock {
|
mutex.withLock {
|
||||||
|
@ -98,7 +98,7 @@ internal class DefaultDownloadKeysForUsers @Inject constructor(
|
||||||
} else {
|
} else {
|
||||||
// No need to chunk, direct request
|
// No need to chunk, direct request
|
||||||
executeRequest(globalErrorReceiver) {
|
executeRequest(globalErrorReceiver) {
|
||||||
apiCall = cryptoApi.downloadKeysForUsers(
|
cryptoApi.downloadKeysForUsers(
|
||||||
KeysQueryBody(
|
KeysQueryBody(
|
||||||
deviceKeys = params.userIds.associateWith { emptyList() },
|
deviceKeys = params.userIds.associateWith { emptyList() },
|
||||||
token = token
|
token = token
|
||||||
|
|
|
@ -34,7 +34,7 @@ internal class DefaultGetDeviceInfoTask @Inject constructor(
|
||||||
|
|
||||||
override suspend fun execute(params: GetDeviceInfoTask.Params): DeviceInfo {
|
override suspend fun execute(params: GetDeviceInfoTask.Params): DeviceInfo {
|
||||||
return executeRequest(globalErrorReceiver) {
|
return executeRequest(globalErrorReceiver) {
|
||||||
apiCall = cryptoApi.getDeviceInfo(params.deviceId)
|
cryptoApi.getDeviceInfo(params.deviceId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ internal class DefaultGetDevicesTask @Inject constructor(
|
||||||
|
|
||||||
override suspend fun execute(params: Unit): DevicesListResponse {
|
override suspend fun execute(params: Unit): DevicesListResponse {
|
||||||
return executeRequest(globalErrorReceiver) {
|
return executeRequest(globalErrorReceiver) {
|
||||||
apiCall = cryptoApi.getDevices()
|
cryptoApi.getDevices()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ internal class DefaultGetKeyChangesTask @Inject constructor(
|
||||||
|
|
||||||
override suspend fun execute(params: GetKeyChangesTask.Params): KeyChangesResponse {
|
override suspend fun execute(params: GetKeyChangesTask.Params): KeyChangesResponse {
|
||||||
return executeRequest(globalErrorReceiver) {
|
return executeRequest(globalErrorReceiver) {
|
||||||
apiCall = cryptoApi.getKeyChanges(params.from, params.to)
|
cryptoApi.getKeyChanges(params.from, params.to)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@ package org.matrix.android.sdk.internal.crypto.tasks
|
||||||
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.session.room.RoomAPI
|
import org.matrix.android.sdk.internal.session.room.RoomAPI
|
||||||
import org.matrix.android.sdk.internal.session.room.send.SendResponse
|
|
||||||
import org.matrix.android.sdk.internal.task.Task
|
import org.matrix.android.sdk.internal.task.Task
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@ -36,14 +35,14 @@ internal class DefaultRedactEventTask @Inject constructor(
|
||||||
private val globalErrorReceiver: GlobalErrorReceiver) : RedactEventTask {
|
private val globalErrorReceiver: GlobalErrorReceiver) : RedactEventTask {
|
||||||
|
|
||||||
override suspend fun execute(params: RedactEventTask.Params): String {
|
override suspend fun execute(params: RedactEventTask.Params): String {
|
||||||
val executeRequest = executeRequest<SendResponse>(globalErrorReceiver) {
|
val response = executeRequest(globalErrorReceiver) {
|
||||||
apiCall = roomAPI.redactEvent(
|
roomAPI.redactEvent(
|
||||||
txId = params.txID,
|
txId = params.txID,
|
||||||
roomId = params.roomId,
|
roomId = params.roomId,
|
||||||
eventId = params.eventId,
|
eventId = params.eventId,
|
||||||
reason = if (params.reason == null) emptyMap() else mapOf("reason" to params.reason)
|
reason = if (params.reason == null) emptyMap() else mapOf("reason" to params.reason)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return executeRequest.eventId
|
return response.eventId
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@ import org.matrix.android.sdk.internal.network.executeRequest
|
||||||
import org.matrix.android.sdk.internal.session.room.RoomAPI
|
import org.matrix.android.sdk.internal.session.room.RoomAPI
|
||||||
import org.matrix.android.sdk.internal.session.room.membership.LoadRoomMembersTask
|
import org.matrix.android.sdk.internal.session.room.membership.LoadRoomMembersTask
|
||||||
import org.matrix.android.sdk.internal.session.room.send.LocalEchoRepository
|
import org.matrix.android.sdk.internal.session.room.send.LocalEchoRepository
|
||||||
import org.matrix.android.sdk.internal.session.room.send.SendResponse
|
|
||||||
import org.matrix.android.sdk.internal.task.Task
|
import org.matrix.android.sdk.internal.task.Task
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@ -52,8 +51,8 @@ internal class DefaultSendEventTask @Inject constructor(
|
||||||
val event = handleEncryption(params)
|
val event = handleEncryption(params)
|
||||||
val localId = event.eventId!!
|
val localId = event.eventId!!
|
||||||
localEchoRepository.updateSendState(localId, params.event.roomId, SendState.SENDING)
|
localEchoRepository.updateSendState(localId, params.event.roomId, SendState.SENDING)
|
||||||
val executeRequest = executeRequest<SendResponse>(globalErrorReceiver) {
|
val response = executeRequest(globalErrorReceiver) {
|
||||||
apiCall = roomAPI.send(
|
roomAPI.send(
|
||||||
localId,
|
localId,
|
||||||
roomId = event.roomId ?: "",
|
roomId = event.roomId ?: "",
|
||||||
content = event.content,
|
content = event.content,
|
||||||
|
@ -61,7 +60,7 @@ internal class DefaultSendEventTask @Inject constructor(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
localEchoRepository.updateSendState(localId, params.event.roomId, SendState.SENT)
|
localEchoRepository.updateSendState(localId, params.event.roomId, SendState.SENT)
|
||||||
return executeRequest.eventId
|
return response.eventId
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
// localEchoRepository.updateSendState(params.event.eventId!!, SendState.UNDELIVERED)
|
// localEchoRepository.updateSendState(params.event.eventId!!, SendState.UNDELIVERED)
|
||||||
throw e
|
throw e
|
||||||
|
|
|
@ -46,14 +46,16 @@ internal class DefaultSendToDeviceTask @Inject constructor(
|
||||||
messages = params.contentMap.map
|
messages = params.contentMap.map
|
||||||
)
|
)
|
||||||
|
|
||||||
return executeRequest(globalErrorReceiver) {
|
return executeRequest(
|
||||||
apiCall = cryptoApi.sendToDevice(
|
globalErrorReceiver,
|
||||||
|
canRetry = true,
|
||||||
|
maxRetriesCount = 3
|
||||||
|
) {
|
||||||
|
cryptoApi.sendToDevice(
|
||||||
params.eventType,
|
params.eventType,
|
||||||
params.transactionId ?: Random.nextInt(Integer.MAX_VALUE).toString(),
|
params.transactionId ?: Random.nextInt(Integer.MAX_VALUE).toString(),
|
||||||
sendToDeviceBody
|
sendToDeviceBody
|
||||||
)
|
)
|
||||||
isRetryable = true
|
|
||||||
maxRetryCount = 3
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@ 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.session.room.RoomAPI
|
import org.matrix.android.sdk.internal.session.room.RoomAPI
|
||||||
import org.matrix.android.sdk.internal.session.room.send.LocalEchoRepository
|
import org.matrix.android.sdk.internal.session.room.send.LocalEchoRepository
|
||||||
import org.matrix.android.sdk.internal.session.room.send.SendResponse
|
|
||||||
import org.matrix.android.sdk.internal.task.Task
|
import org.matrix.android.sdk.internal.task.Task
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@ -45,8 +44,8 @@ internal class DefaultSendVerificationMessageTask @Inject constructor(
|
||||||
|
|
||||||
try {
|
try {
|
||||||
localEchoRepository.updateSendState(localId, event.roomId, SendState.SENDING)
|
localEchoRepository.updateSendState(localId, event.roomId, SendState.SENDING)
|
||||||
val executeRequest = executeRequest<SendResponse>(globalErrorReceiver) {
|
val response = executeRequest(globalErrorReceiver) {
|
||||||
apiCall = roomAPI.send(
|
roomAPI.send(
|
||||||
localId,
|
localId,
|
||||||
roomId = event.roomId ?: "",
|
roomId = event.roomId ?: "",
|
||||||
content = event.content,
|
content = event.content,
|
||||||
|
@ -54,7 +53,7 @@ internal class DefaultSendVerificationMessageTask @Inject constructor(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
localEchoRepository.updateSendState(localId, event.roomId, SendState.SENT)
|
localEchoRepository.updateSendState(localId, event.roomId, SendState.SENT)
|
||||||
return executeRequest.eventId
|
return response.eventId
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
localEchoRepository.updateSendState(localId, event.roomId, SendState.UNDELIVERED)
|
localEchoRepository.updateSendState(localId, event.roomId, SendState.UNDELIVERED)
|
||||||
throw e
|
throw e
|
||||||
|
|
|
@ -42,7 +42,7 @@ internal class DefaultSetDeviceNameTask @Inject constructor(
|
||||||
displayName = params.deviceName
|
displayName = params.deviceName
|
||||||
)
|
)
|
||||||
return executeRequest(globalErrorReceiver) {
|
return executeRequest(globalErrorReceiver) {
|
||||||
apiCall = cryptoApi.updateDeviceInfo(params.deviceId, body)
|
cryptoApi.updateDeviceInfo(params.deviceId, body)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ internal class DefaultUploadKeysTask @Inject constructor(
|
||||||
Timber.i("## Uploading device keys -> $body")
|
Timber.i("## Uploading device keys -> $body")
|
||||||
|
|
||||||
return executeRequest(globalErrorReceiver) {
|
return executeRequest(globalErrorReceiver) {
|
||||||
apiCall = cryptoApi.uploadKeys(body)
|
cryptoApi.uploadKeys(body)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@ package org.matrix.android.sdk.internal.crypto.tasks
|
||||||
|
|
||||||
import org.matrix.android.sdk.api.failure.Failure
|
import org.matrix.android.sdk.api.failure.Failure
|
||||||
import org.matrix.android.sdk.internal.crypto.api.CryptoApi
|
import org.matrix.android.sdk.internal.crypto.api.CryptoApi
|
||||||
import org.matrix.android.sdk.internal.crypto.model.rest.SignatureUploadResponse
|
|
||||||
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
|
||||||
|
@ -36,10 +35,12 @@ internal class DefaultUploadSignaturesTask @Inject constructor(
|
||||||
|
|
||||||
override suspend fun execute(params: UploadSignaturesTask.Params) {
|
override suspend fun execute(params: UploadSignaturesTask.Params) {
|
||||||
try {
|
try {
|
||||||
val response = executeRequest<SignatureUploadResponse>(globalErrorReceiver) {
|
val response = executeRequest(
|
||||||
this.isRetryable = true
|
globalErrorReceiver,
|
||||||
this.maxRetryCount = 10
|
canRetry = true,
|
||||||
this.apiCall = cryptoApi.uploadSignatures(params.signatures)
|
maxRetriesCount = 10
|
||||||
|
) {
|
||||||
|
cryptoApi.uploadSignatures(params.signatures)
|
||||||
}
|
}
|
||||||
if (response.failures?.isNotEmpty() == true) {
|
if (response.failures?.isNotEmpty() == true) {
|
||||||
throw Throwable(response.failures.toString())
|
throw Throwable(response.failures.toString())
|
||||||
|
|
|
@ -19,7 +19,6 @@ package org.matrix.android.sdk.internal.crypto.tasks
|
||||||
import org.matrix.android.sdk.api.failure.Failure
|
import org.matrix.android.sdk.api.failure.Failure
|
||||||
import org.matrix.android.sdk.internal.crypto.api.CryptoApi
|
import org.matrix.android.sdk.internal.crypto.api.CryptoApi
|
||||||
import org.matrix.android.sdk.internal.crypto.model.CryptoCrossSigningKey
|
import org.matrix.android.sdk.internal.crypto.model.CryptoCrossSigningKey
|
||||||
import org.matrix.android.sdk.internal.crypto.model.rest.KeysQueryResponse
|
|
||||||
import org.matrix.android.sdk.api.auth.UIABaseAuth
|
import org.matrix.android.sdk.api.auth.UIABaseAuth
|
||||||
import org.matrix.android.sdk.internal.crypto.model.rest.UploadSigningKeysBody
|
import org.matrix.android.sdk.internal.crypto.model.rest.UploadSigningKeysBody
|
||||||
import org.matrix.android.sdk.internal.crypto.model.toRest
|
import org.matrix.android.sdk.internal.crypto.model.toRest
|
||||||
|
@ -61,8 +60,8 @@ internal class DefaultUploadSigningKeysTask @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun doRequest(uploadQuery: UploadSigningKeysBody) {
|
private suspend fun doRequest(uploadQuery: UploadSigningKeysBody) {
|
||||||
val keysQueryResponse = executeRequest<KeysQueryResponse>(globalErrorReceiver) {
|
val keysQueryResponse = executeRequest(globalErrorReceiver) {
|
||||||
apiCall = cryptoApi.uploadSigningKeys(uploadQuery)
|
cryptoApi.uploadSigningKeys(uploadQuery)
|
||||||
}
|
}
|
||||||
if (keysQueryResponse.failures?.isNotEmpty() == true) {
|
if (keysQueryResponse.failures?.isNotEmpty() == true) {
|
||||||
throw UploadSigningKeys(keysQueryResponse.failures)
|
throw UploadSigningKeys(keysQueryResponse.failures)
|
||||||
|
|
|
@ -18,10 +18,9 @@
|
||||||
package org.matrix.android.sdk.internal.federation
|
package org.matrix.android.sdk.internal.federation
|
||||||
|
|
||||||
import org.matrix.android.sdk.internal.network.NetworkConstants
|
import org.matrix.android.sdk.internal.network.NetworkConstants
|
||||||
import retrofit2.Call
|
|
||||||
import retrofit2.http.GET
|
import retrofit2.http.GET
|
||||||
|
|
||||||
internal interface FederationAPI {
|
internal interface FederationAPI {
|
||||||
@GET(NetworkConstants.URI_FEDERATION_PATH + "version")
|
@GET(NetworkConstants.URI_FEDERATION_PATH + "version")
|
||||||
fun getVersion(): Call<FederationGetVersionResult>
|
suspend fun getVersion(): FederationGetVersionResult
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,8 +28,8 @@ internal class DefaultGetFederationVersionTask @Inject constructor(
|
||||||
) : GetFederationVersionTask {
|
) : GetFederationVersionTask {
|
||||||
|
|
||||||
override suspend fun execute(params: Unit): FederationVersion {
|
override suspend fun execute(params: Unit): FederationVersion {
|
||||||
val result = executeRequest<FederationGetVersionResult>(null) {
|
val result = executeRequest(null) {
|
||||||
apiCall = federationAPI.getVersion()
|
federationAPI.getVersion()
|
||||||
}
|
}
|
||||||
|
|
||||||
return FederationVersion(
|
return FederationVersion(
|
||||||
|
|
|
@ -19,38 +19,45 @@ package org.matrix.android.sdk.internal.network
|
||||||
import kotlinx.coroutines.CancellationException
|
import kotlinx.coroutines.CancellationException
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import org.matrix.android.sdk.api.failure.Failure
|
import org.matrix.android.sdk.api.failure.Failure
|
||||||
|
import org.matrix.android.sdk.api.failure.getRetryDelay
|
||||||
import org.matrix.android.sdk.api.failure.shouldBeRetried
|
import org.matrix.android.sdk.api.failure.shouldBeRetried
|
||||||
import org.matrix.android.sdk.internal.network.ssl.CertUtil
|
import org.matrix.android.sdk.internal.network.ssl.CertUtil
|
||||||
import retrofit2.Call
|
import retrofit2.HttpException
|
||||||
import retrofit2.awaitResponse
|
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
||||||
internal suspend inline fun <DATA : Any> executeRequest(globalErrorReceiver: GlobalErrorReceiver?,
|
/**
|
||||||
block: Request<DATA>.() -> Unit) = Request<DATA>(globalErrorReceiver).apply(block).execute()
|
* Execute a request from the requestBlock and handle some of the Exception it could generate
|
||||||
|
*
|
||||||
|
* @param globalErrorReceiver will be use to notify error such as invalid token error. See [GlobalError]
|
||||||
|
* @param canRetry if set to true, the request will be executed again in case of error, after a delay
|
||||||
|
* @param initialDelayBeforeRetry the first delay to wait before a request is retried. Will be doubled after each retry
|
||||||
|
* @param maxDelayBeforeRetry the max delay to wait before a retry
|
||||||
|
* @param maxRetriesCount the max number of retries
|
||||||
|
* @param requestBlock a suspend lambda to perform the network request
|
||||||
|
*/
|
||||||
|
internal suspend inline fun <DATA> executeRequest(globalErrorReceiver: GlobalErrorReceiver?,
|
||||||
|
canRetry: Boolean = false,
|
||||||
|
initialDelayBeforeRetry: Long = 100L,
|
||||||
|
maxDelayBeforeRetry: Long = 10_000L,
|
||||||
|
maxRetriesCount: Int = Int.MAX_VALUE,
|
||||||
|
noinline requestBlock: suspend () -> DATA): DATA {
|
||||||
|
var currentRetryCount = 0
|
||||||
|
var currentDelay = initialDelayBeforeRetry
|
||||||
|
|
||||||
internal class Request<DATA : Any>(private val globalErrorReceiver: GlobalErrorReceiver?) {
|
while (true) {
|
||||||
|
try {
|
||||||
var isRetryable = false
|
return requestBlock()
|
||||||
var initialDelay: Long = 100L
|
} catch (throwable: Throwable) {
|
||||||
var maxDelay: Long = 10_000L
|
val exception = when (throwable) {
|
||||||
var maxRetryCount = Int.MAX_VALUE
|
is KotlinNullPointerException -> IllegalStateException("The request returned a null body")
|
||||||
private var currentRetryCount = 0
|
is HttpException -> throwable.toFailure(globalErrorReceiver)
|
||||||
private var currentDelay = initialDelay
|
else -> throwable
|
||||||
lateinit var apiCall: Call<DATA>
|
|
||||||
|
|
||||||
suspend fun execute(): DATA {
|
|
||||||
return try {
|
|
||||||
val response = apiCall.clone().awaitResponse()
|
|
||||||
if (response.isSuccessful) {
|
|
||||||
response.body()
|
|
||||||
?: throw IllegalStateException("The request returned a null body")
|
|
||||||
} else {
|
|
||||||
throw response.toFailure(globalErrorReceiver)
|
|
||||||
}
|
}
|
||||||
} catch (exception: Throwable) {
|
|
||||||
// Log some details about the request which has failed
|
// Log some details about the request which has failed. This is less useful than before...
|
||||||
Timber.e("Exception when executing request ${apiCall.request().method} ${apiCall.request().url.toString().substringBefore("?")}")
|
// Timber.e("Exception when executing request ${apiCall.request().method} ${apiCall.request().url.toString().substringBefore("?")}")
|
||||||
|
Timber.e("Exception when executing request")
|
||||||
|
|
||||||
// Check if this is a certificateException
|
// Check if this is a certificateException
|
||||||
CertUtil.getCertificateException(exception)
|
CertUtil.getCertificateException(exception)
|
||||||
|
@ -61,10 +68,11 @@ internal class Request<DATA : Any>(private val globalErrorReceiver: GlobalErrorR
|
||||||
// }
|
// }
|
||||||
?.also { unrecognizedCertificateException -> throw unrecognizedCertificateException }
|
?.also { unrecognizedCertificateException -> throw unrecognizedCertificateException }
|
||||||
|
|
||||||
if (isRetryable && currentRetryCount++ < maxRetryCount && exception.shouldBeRetried()) {
|
if (canRetry && currentRetryCount++ < maxRetriesCount && exception.shouldBeRetried()) {
|
||||||
delay(currentDelay)
|
// In case of 429, ensure we wait enough
|
||||||
currentDelay = (currentDelay * 2L).coerceAtMost(maxDelay)
|
delay(currentDelay.coerceAtLeast(exception.getRetryDelay(0)))
|
||||||
return execute()
|
currentDelay = currentDelay.times(2L).coerceAtMost(maxDelayBeforeRetry)
|
||||||
|
// Try again (loop)
|
||||||
} else {
|
} else {
|
||||||
throw when (exception) {
|
throw when (exception) {
|
||||||
is IOException -> Failure.NetworkConnection(exception)
|
is IOException -> Failure.NetworkConnection(exception)
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.matrix.android.sdk.api.failure.MatrixError
|
||||||
import org.matrix.android.sdk.internal.di.MoshiProvider
|
import org.matrix.android.sdk.internal.di.MoshiProvider
|
||||||
import kotlinx.coroutines.suspendCancellableCoroutine
|
import kotlinx.coroutines.suspendCancellableCoroutine
|
||||||
import okhttp3.ResponseBody
|
import okhttp3.ResponseBody
|
||||||
|
import retrofit2.HttpException
|
||||||
import retrofit2.Response
|
import retrofit2.Response
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
@ -57,6 +58,13 @@ internal fun <T> Response<T>.toFailure(globalErrorReceiver: GlobalErrorReceiver?
|
||||||
return toFailure(errorBody(), code(), globalErrorReceiver)
|
return toFailure(errorBody(), code(), globalErrorReceiver)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a HttpException to a Failure, and eventually parse errorBody to convert it to a MatrixError
|
||||||
|
*/
|
||||||
|
internal fun HttpException.toFailure(globalErrorReceiver: GlobalErrorReceiver?): Failure {
|
||||||
|
return toFailure(response()?.errorBody(), code(), globalErrorReceiver)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a okhttp3 Response to a Failure, and eventually parse errorBody to convert it to a MatrixError
|
* Convert a okhttp3 Response to a Failure, and eventually parse errorBody to convert it to a MatrixError
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
package org.matrix.android.sdk.internal.raw
|
package org.matrix.android.sdk.internal.raw
|
||||||
|
|
||||||
import com.zhuinden.monarchy.Monarchy
|
import com.zhuinden.monarchy.Monarchy
|
||||||
import okhttp3.ResponseBody
|
|
||||||
import org.matrix.android.sdk.api.cache.CacheStrategy
|
import org.matrix.android.sdk.api.cache.CacheStrategy
|
||||||
import org.matrix.android.sdk.internal.database.model.RawCacheEntity
|
import org.matrix.android.sdk.internal.database.model.RawCacheEntity
|
||||||
import org.matrix.android.sdk.internal.database.query.get
|
import org.matrix.android.sdk.internal.database.query.get
|
||||||
|
@ -58,8 +57,8 @@ internal class DefaultGetUrlTask @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun doRequest(url: String): String {
|
private suspend fun doRequest(url: String): String {
|
||||||
return executeRequest<ResponseBody>(null) {
|
return executeRequest(null) {
|
||||||
apiCall = rawAPI.getUrl(url)
|
rawAPI.getUrl(url)
|
||||||
}
|
}
|
||||||
.string()
|
.string()
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,11 +18,10 @@
|
||||||
package org.matrix.android.sdk.internal.raw
|
package org.matrix.android.sdk.internal.raw
|
||||||
|
|
||||||
import okhttp3.ResponseBody
|
import okhttp3.ResponseBody
|
||||||
import retrofit2.Call
|
|
||||||
import retrofit2.http.GET
|
import retrofit2.http.GET
|
||||||
import retrofit2.http.Url
|
import retrofit2.http.Url
|
||||||
|
|
||||||
internal interface RawAPI {
|
internal interface RawAPI {
|
||||||
@GET
|
@GET
|
||||||
fun getUrl(@Url url: String): Call<ResponseBody>
|
suspend fun getUrl(@Url url: String): ResponseBody
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
package org.matrix.android.sdk.internal.session.account
|
package org.matrix.android.sdk.internal.session.account
|
||||||
|
|
||||||
import org.matrix.android.sdk.internal.network.NetworkConstants
|
import org.matrix.android.sdk.internal.network.NetworkConstants
|
||||||
import retrofit2.Call
|
|
||||||
import retrofit2.http.Body
|
import retrofit2.http.Body
|
||||||
import retrofit2.http.POST
|
import retrofit2.http.POST
|
||||||
|
|
||||||
|
@ -28,7 +27,7 @@ internal interface AccountAPI {
|
||||||
* @param params parameters to change password.
|
* @param params parameters to change password.
|
||||||
*/
|
*/
|
||||||
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "account/password")
|
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "account/password")
|
||||||
fun changePassword(@Body params: ChangePasswordParams): Call<Unit>
|
suspend fun changePassword(@Body params: ChangePasswordParams)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deactivate the user account
|
* Deactivate the user account
|
||||||
|
@ -36,5 +35,5 @@ internal interface AccountAPI {
|
||||||
* @param params the deactivate account params
|
* @param params the deactivate account params
|
||||||
*/
|
*/
|
||||||
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "account/deactivate")
|
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "account/deactivate")
|
||||||
fun deactivate(@Body params: DeactivateAccountParams): Call<Unit>
|
suspend fun deactivate(@Body params: DeactivateAccountParams)
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,8 +39,8 @@ internal class DefaultChangePasswordTask @Inject constructor(
|
||||||
override suspend fun execute(params: ChangePasswordTask.Params) {
|
override suspend fun execute(params: ChangePasswordTask.Params) {
|
||||||
val changePasswordParams = ChangePasswordParams.create(userId, params.password, params.newPassword)
|
val changePasswordParams = ChangePasswordParams.create(userId, params.password, params.newPassword)
|
||||||
try {
|
try {
|
||||||
executeRequest<Unit>(globalErrorReceiver) {
|
executeRequest(globalErrorReceiver) {
|
||||||
apiCall = accountAPI.changePassword(changePasswordParams)
|
accountAPI.changePassword(changePasswordParams)
|
||||||
}
|
}
|
||||||
} catch (throwable: Throwable) {
|
} catch (throwable: Throwable) {
|
||||||
val registrationFlowResponse = throwable.toRegistrationFlowResponse()
|
val registrationFlowResponse = throwable.toRegistrationFlowResponse()
|
||||||
|
@ -49,8 +49,8 @@ internal class DefaultChangePasswordTask @Inject constructor(
|
||||||
/* Avoid infinite loop */
|
/* Avoid infinite loop */
|
||||||
&& changePasswordParams.auth?.session == null) {
|
&& changePasswordParams.auth?.session == null) {
|
||||||
// Retry with authentication
|
// Retry with authentication
|
||||||
executeRequest<Unit>(globalErrorReceiver) {
|
executeRequest(globalErrorReceiver) {
|
||||||
apiCall = accountAPI.changePassword(
|
accountAPI.changePassword(
|
||||||
changePasswordParams.copy(auth = changePasswordParams.auth?.copy(session = registrationFlowResponse.session))
|
changePasswordParams.copy(auth = changePasswordParams.auth?.copy(session = registrationFlowResponse.session))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,8 +46,8 @@ internal class DefaultDeactivateAccountTask @Inject constructor(
|
||||||
val deactivateAccountParams = DeactivateAccountParams.create(params.userAuthParam, params.eraseAllData)
|
val deactivateAccountParams = DeactivateAccountParams.create(params.userAuthParam, params.eraseAllData)
|
||||||
|
|
||||||
val canCleanup = try {
|
val canCleanup = try {
|
||||||
executeRequest<Unit>(globalErrorReceiver) {
|
executeRequest(globalErrorReceiver) {
|
||||||
apiCall = accountAPI.deactivate(deactivateAccountParams)
|
accountAPI.deactivate(deactivateAccountParams)
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
} catch (throwable: Throwable) {
|
} catch (throwable: Throwable) {
|
||||||
|
|
|
@ -31,7 +31,7 @@ internal class DefaultGetTurnServerTask @Inject constructor(private val voipAPI:
|
||||||
|
|
||||||
override suspend fun execute(params: Params): TurnServerResponse {
|
override suspend fun execute(params: Params): TurnServerResponse {
|
||||||
return executeRequest(globalErrorReceiver) {
|
return executeRequest(globalErrorReceiver) {
|
||||||
apiCall = voipAPI.getTurnServer()
|
voipAPI.getTurnServer()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,11 +18,10 @@ package org.matrix.android.sdk.internal.session.call
|
||||||
|
|
||||||
import org.matrix.android.sdk.api.session.call.TurnServerResponse
|
import org.matrix.android.sdk.api.session.call.TurnServerResponse
|
||||||
import org.matrix.android.sdk.internal.network.NetworkConstants
|
import org.matrix.android.sdk.internal.network.NetworkConstants
|
||||||
import retrofit2.Call
|
|
||||||
import retrofit2.http.GET
|
import retrofit2.http.GET
|
||||||
|
|
||||||
internal interface VoipApi {
|
internal interface VoipApi {
|
||||||
|
|
||||||
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "voip/turnServer")
|
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "voip/turnServer")
|
||||||
fun getTurnServer(): Call<TurnServerResponse>
|
suspend fun getTurnServer(): TurnServerResponse
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@ package org.matrix.android.sdk.internal.session.directory
|
||||||
import org.matrix.android.sdk.internal.network.NetworkConstants
|
import org.matrix.android.sdk.internal.network.NetworkConstants
|
||||||
import org.matrix.android.sdk.internal.session.room.alias.AddRoomAliasBody
|
import org.matrix.android.sdk.internal.session.room.alias.AddRoomAliasBody
|
||||||
import org.matrix.android.sdk.internal.session.room.alias.RoomAliasDescription
|
import org.matrix.android.sdk.internal.session.room.alias.RoomAliasDescription
|
||||||
import retrofit2.Call
|
|
||||||
import retrofit2.http.Body
|
import retrofit2.http.Body
|
||||||
import retrofit2.http.DELETE
|
import retrofit2.http.DELETE
|
||||||
import retrofit2.http.GET
|
import retrofit2.http.GET
|
||||||
|
@ -33,7 +32,7 @@ internal interface DirectoryAPI {
|
||||||
* @param roomAlias the room alias.
|
* @param roomAlias the room alias.
|
||||||
*/
|
*/
|
||||||
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "directory/room/{roomAlias}")
|
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "directory/room/{roomAlias}")
|
||||||
fun getRoomIdByAlias(@Path("roomAlias") roomAlias: String): Call<RoomAliasDescription>
|
suspend fun getRoomIdByAlias(@Path("roomAlias") roomAlias: String): RoomAliasDescription
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the room directory visibility.
|
* Get the room directory visibility.
|
||||||
|
@ -41,7 +40,7 @@ internal interface DirectoryAPI {
|
||||||
* @param roomId the room id.
|
* @param roomId the room id.
|
||||||
*/
|
*/
|
||||||
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "directory/list/room/{roomId}")
|
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "directory/list/room/{roomId}")
|
||||||
fun getRoomDirectoryVisibility(@Path("roomId") roomId: String): Call<RoomDirectoryVisibilityJson>
|
suspend fun getRoomDirectoryVisibility(@Path("roomId") roomId: String): RoomDirectoryVisibilityJson
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the room directory visibility.
|
* Set the room directory visibility.
|
||||||
|
@ -50,21 +49,21 @@ internal interface DirectoryAPI {
|
||||||
* @param body the body containing the new directory visibility
|
* @param body the body containing the new directory visibility
|
||||||
*/
|
*/
|
||||||
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "directory/list/room/{roomId}")
|
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "directory/list/room/{roomId}")
|
||||||
fun setRoomDirectoryVisibility(@Path("roomId") roomId: String,
|
suspend fun setRoomDirectoryVisibility(@Path("roomId") roomId: String,
|
||||||
@Body body: RoomDirectoryVisibilityJson): Call<Unit>
|
@Body body: RoomDirectoryVisibilityJson)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add alias to the room.
|
* Add alias to the room.
|
||||||
* @param roomAlias the room alias.
|
* @param roomAlias the room alias.
|
||||||
*/
|
*/
|
||||||
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "directory/room/{roomAlias}")
|
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "directory/room/{roomAlias}")
|
||||||
fun addRoomAlias(@Path("roomAlias") roomAlias: String,
|
suspend fun addRoomAlias(@Path("roomAlias") roomAlias: String,
|
||||||
@Body body: AddRoomAliasBody): Call<Unit>
|
@Body body: AddRoomAliasBody)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a room alias
|
* Delete a room alias
|
||||||
* @param roomAlias the room alias.
|
* @param roomAlias the room alias.
|
||||||
*/
|
*/
|
||||||
@DELETE(NetworkConstants.URI_API_PREFIX_PATH_R0 + "directory/room/{roomAlias}")
|
@DELETE(NetworkConstants.URI_API_PREFIX_PATH_R0 + "directory/room/{roomAlias}")
|
||||||
fun deleteRoomAlias(@Path("roomAlias") roomAlias: String): Call<Unit>
|
suspend fun deleteRoomAlias(@Path("roomAlias") roomAlias: String)
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
package org.matrix.android.sdk.internal.session.filter
|
package org.matrix.android.sdk.internal.session.filter
|
||||||
|
|
||||||
import org.matrix.android.sdk.internal.network.NetworkConstants
|
import org.matrix.android.sdk.internal.network.NetworkConstants
|
||||||
import retrofit2.Call
|
|
||||||
import retrofit2.http.Body
|
import retrofit2.http.Body
|
||||||
import retrofit2.http.GET
|
import retrofit2.http.GET
|
||||||
import retrofit2.http.POST
|
import retrofit2.http.POST
|
||||||
|
@ -32,8 +31,8 @@ internal interface FilterApi {
|
||||||
* @param body the Json representation of a FilterBody object
|
* @param body the Json representation of a FilterBody object
|
||||||
*/
|
*/
|
||||||
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "user/{userId}/filter")
|
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "user/{userId}/filter")
|
||||||
fun uploadFilter(@Path("userId") userId: String,
|
suspend fun uploadFilter(@Path("userId") userId: String,
|
||||||
@Body body: Filter): Call<FilterResponse>
|
@Body body: Filter): FilterResponse
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a filter with a given filterId from the homeserver
|
* Gets a filter with a given filterId from the homeserver
|
||||||
|
@ -43,6 +42,6 @@ internal interface FilterApi {
|
||||||
* @return Filter
|
* @return Filter
|
||||||
*/
|
*/
|
||||||
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "user/{userId}/filter/{filterId}")
|
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "user/{userId}/filter/{filterId}")
|
||||||
fun getFilterById(@Path("userId") userId: String,
|
suspend fun getFilterById(@Path("userId") userId: String,
|
||||||
@Path("filterId") filterId: String): Call<Filter>
|
@Path("filterId") filterId: String): Filter
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,9 +59,9 @@ internal class DefaultSaveFilterTask @Inject constructor(
|
||||||
}
|
}
|
||||||
val updated = filterRepository.storeFilter(filterBody, roomFilter)
|
val updated = filterRepository.storeFilter(filterBody, roomFilter)
|
||||||
if (updated) {
|
if (updated) {
|
||||||
val filterResponse = executeRequest<FilterResponse>(globalErrorReceiver) {
|
val filterResponse = executeRequest(globalErrorReceiver) {
|
||||||
// TODO auto retry
|
// TODO auto retry
|
||||||
apiCall = filterAPI.uploadFilter(userId, filterBody)
|
filterAPI.uploadFilter(userId, filterBody)
|
||||||
}
|
}
|
||||||
filterRepository.storeFilterId(filterBody, filterResponse.filterId)
|
filterRepository.storeFilterId(filterBody, filterResponse.filterId)
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,14 +64,14 @@ internal class DefaultGetGroupDataTask @Inject constructor(
|
||||||
}
|
}
|
||||||
Timber.v("Fetch data for group with ids: ${groupIds.joinToString(";")}")
|
Timber.v("Fetch data for group with ids: ${groupIds.joinToString(";")}")
|
||||||
val data = groupIds.map { groupId ->
|
val data = groupIds.map { groupId ->
|
||||||
val groupSummary = executeRequest<GroupSummaryResponse>(globalErrorReceiver) {
|
val groupSummary = executeRequest(globalErrorReceiver) {
|
||||||
apiCall = groupAPI.getSummary(groupId)
|
groupAPI.getSummary(groupId)
|
||||||
}
|
}
|
||||||
val groupRooms = executeRequest<GroupRooms>(globalErrorReceiver) {
|
val groupRooms = executeRequest(globalErrorReceiver) {
|
||||||
apiCall = groupAPI.getRooms(groupId)
|
groupAPI.getRooms(groupId)
|
||||||
}
|
}
|
||||||
val groupUsers = executeRequest<GroupUsers>(globalErrorReceiver) {
|
val groupUsers = executeRequest(globalErrorReceiver) {
|
||||||
apiCall = groupAPI.getUsers(groupId)
|
groupAPI.getUsers(groupId)
|
||||||
}
|
}
|
||||||
GroupData(groupId, groupSummary, groupRooms, groupUsers)
|
GroupData(groupId, groupSummary, groupRooms, groupUsers)
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ import org.matrix.android.sdk.internal.network.NetworkConstants
|
||||||
import org.matrix.android.sdk.internal.session.group.model.GroupRooms
|
import org.matrix.android.sdk.internal.session.group.model.GroupRooms
|
||||||
import org.matrix.android.sdk.internal.session.group.model.GroupSummaryResponse
|
import org.matrix.android.sdk.internal.session.group.model.GroupSummaryResponse
|
||||||
import org.matrix.android.sdk.internal.session.group.model.GroupUsers
|
import org.matrix.android.sdk.internal.session.group.model.GroupUsers
|
||||||
import retrofit2.Call
|
|
||||||
import retrofit2.http.GET
|
import retrofit2.http.GET
|
||||||
import retrofit2.http.Path
|
import retrofit2.http.Path
|
||||||
|
|
||||||
|
@ -32,7 +31,7 @@ internal interface GroupAPI {
|
||||||
* @param groupId the group id
|
* @param groupId the group id
|
||||||
*/
|
*/
|
||||||
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "groups/{groupId}/summary")
|
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "groups/{groupId}/summary")
|
||||||
fun getSummary(@Path("groupId") groupId: String): Call<GroupSummaryResponse>
|
suspend fun getSummary(@Path("groupId") groupId: String): GroupSummaryResponse
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request the rooms list.
|
* Request the rooms list.
|
||||||
|
@ -40,7 +39,7 @@ internal interface GroupAPI {
|
||||||
* @param groupId the group id
|
* @param groupId the group id
|
||||||
*/
|
*/
|
||||||
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "groups/{groupId}/rooms")
|
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "groups/{groupId}/rooms")
|
||||||
fun getRooms(@Path("groupId") groupId: String): Call<GroupRooms>
|
suspend fun getRooms(@Path("groupId") groupId: String): GroupRooms
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request the users list.
|
* Request the users list.
|
||||||
|
@ -48,5 +47,5 @@ internal interface GroupAPI {
|
||||||
* @param groupId the group id
|
* @param groupId the group id
|
||||||
*/
|
*/
|
||||||
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "groups/{groupId}/users")
|
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "groups/{groupId}/users")
|
||||||
fun getUsers(@Path("groupId") groupId: String): Call<GroupUsers>
|
suspend fun getUsers(@Path("groupId") groupId: String): GroupUsers
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@ package org.matrix.android.sdk.internal.session.homeserver
|
||||||
|
|
||||||
import org.matrix.android.sdk.internal.auth.version.Versions
|
import org.matrix.android.sdk.internal.auth.version.Versions
|
||||||
import org.matrix.android.sdk.internal.network.NetworkConstants
|
import org.matrix.android.sdk.internal.network.NetworkConstants
|
||||||
import retrofit2.Call
|
|
||||||
import retrofit2.http.GET
|
import retrofit2.http.GET
|
||||||
|
|
||||||
internal interface CapabilitiesAPI {
|
internal interface CapabilitiesAPI {
|
||||||
|
@ -26,17 +25,17 @@ internal interface CapabilitiesAPI {
|
||||||
* Request the homeserver capabilities
|
* Request the homeserver capabilities
|
||||||
*/
|
*/
|
||||||
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "capabilities")
|
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "capabilities")
|
||||||
fun getCapabilities(): Call<GetCapabilitiesResult>
|
suspend fun getCapabilities(): GetCapabilitiesResult
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request the versions
|
* Request the versions
|
||||||
*/
|
*/
|
||||||
@GET(NetworkConstants.URI_API_PREFIX_PATH_ + "versions")
|
@GET(NetworkConstants.URI_API_PREFIX_PATH_ + "versions")
|
||||||
fun getVersions(): Call<Versions>
|
suspend fun getVersions(): Versions
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ping the homeserver. We do not care about the returned data, so there is no use to parse them
|
* Ping the homeserver. We do not care about the returned data, so there is no use to parse them
|
||||||
*/
|
*/
|
||||||
@GET(NetworkConstants.URI_API_PREFIX_PATH_ + "versions")
|
@GET(NetworkConstants.URI_API_PREFIX_PATH_ + "versions")
|
||||||
fun ping(): Call<Unit>
|
suspend fun ping()
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,20 +71,20 @@ internal class DefaultGetHomeServerCapabilitiesTask @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
val capabilities = runCatching {
|
val capabilities = runCatching {
|
||||||
executeRequest<GetCapabilitiesResult>(globalErrorReceiver) {
|
executeRequest(globalErrorReceiver) {
|
||||||
apiCall = capabilitiesAPI.getCapabilities()
|
capabilitiesAPI.getCapabilities()
|
||||||
}
|
}
|
||||||
}.getOrNull()
|
}.getOrNull()
|
||||||
|
|
||||||
val mediaConfig = runCatching {
|
val mediaConfig = runCatching {
|
||||||
executeRequest<GetMediaConfigResult>(globalErrorReceiver) {
|
executeRequest(globalErrorReceiver) {
|
||||||
apiCall = mediaAPI.getMediaConfig()
|
mediaAPI.getMediaConfig()
|
||||||
}
|
}
|
||||||
}.getOrNull()
|
}.getOrNull()
|
||||||
|
|
||||||
val versions = runCatching {
|
val versions = runCatching {
|
||||||
executeRequest<Versions>(null) {
|
executeRequest(null) {
|
||||||
apiCall = capabilitiesAPI.getVersions()
|
capabilitiesAPI.getVersions()
|
||||||
}
|
}
|
||||||
}.getOrNull()
|
}.getOrNull()
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,8 @@ internal class HomeServerPinger @Inject constructor(private val taskExecutor: Ta
|
||||||
|
|
||||||
suspend fun canReachHomeServer(): Boolean {
|
suspend fun canReachHomeServer(): Boolean {
|
||||||
return try {
|
return try {
|
||||||
executeRequest<Unit>(null) {
|
executeRequest(null) {
|
||||||
apiCall = capabilitiesAPI.ping()
|
capabilitiesAPI.ping()
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
} catch (throwable: Throwable) {
|
} catch (throwable: Throwable) {
|
||||||
|
|
|
@ -26,7 +26,6 @@ import org.matrix.android.sdk.internal.session.identity.model.IdentityRequestOwn
|
||||||
import org.matrix.android.sdk.internal.session.identity.model.IdentityRequestTokenForEmailBody
|
import org.matrix.android.sdk.internal.session.identity.model.IdentityRequestTokenForEmailBody
|
||||||
import org.matrix.android.sdk.internal.session.identity.model.IdentityRequestTokenForMsisdnBody
|
import org.matrix.android.sdk.internal.session.identity.model.IdentityRequestTokenForMsisdnBody
|
||||||
import org.matrix.android.sdk.internal.session.identity.model.IdentityRequestTokenResponse
|
import org.matrix.android.sdk.internal.session.identity.model.IdentityRequestTokenResponse
|
||||||
import retrofit2.Call
|
|
||||||
import retrofit2.http.Body
|
import retrofit2.http.Body
|
||||||
import retrofit2.http.GET
|
import retrofit2.http.GET
|
||||||
import retrofit2.http.POST
|
import retrofit2.http.POST
|
||||||
|
@ -43,20 +42,20 @@ internal interface IdentityAPI {
|
||||||
* Ref: https://matrix.org/docs/spec/identity_service/latest#get-matrix-identity-v2-account
|
* Ref: https://matrix.org/docs/spec/identity_service/latest#get-matrix-identity-v2-account
|
||||||
*/
|
*/
|
||||||
@GET(NetworkConstants.URI_IDENTITY_PATH_V2 + "account")
|
@GET(NetworkConstants.URI_IDENTITY_PATH_V2 + "account")
|
||||||
fun getAccount(): Call<IdentityAccountResponse>
|
suspend fun getAccount(): IdentityAccountResponse
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs out the access token, preventing it from being used to authenticate future requests to the server.
|
* Logs out the access token, preventing it from being used to authenticate future requests to the server.
|
||||||
*/
|
*/
|
||||||
@POST(NetworkConstants.URI_IDENTITY_PATH_V2 + "account/logout")
|
@POST(NetworkConstants.URI_IDENTITY_PATH_V2 + "account/logout")
|
||||||
fun logout(): Call<Unit>
|
suspend fun logout()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request the hash detail to request a bunch of 3PIDs
|
* Request the hash detail to request a bunch of 3PIDs
|
||||||
* Ref: https://matrix.org/docs/spec/identity_service/latest#get-matrix-identity-v2-hash-details
|
* Ref: https://matrix.org/docs/spec/identity_service/latest#get-matrix-identity-v2-hash-details
|
||||||
*/
|
*/
|
||||||
@GET(NetworkConstants.URI_IDENTITY_PATH_V2 + "hash_details")
|
@GET(NetworkConstants.URI_IDENTITY_PATH_V2 + "hash_details")
|
||||||
fun hashDetails(): Call<IdentityHashDetailResponse>
|
suspend fun hashDetails(): IdentityHashDetailResponse
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request a bunch of 3PIDs
|
* Request a bunch of 3PIDs
|
||||||
|
@ -65,7 +64,7 @@ internal interface IdentityAPI {
|
||||||
* @param body the body request
|
* @param body the body request
|
||||||
*/
|
*/
|
||||||
@POST(NetworkConstants.URI_IDENTITY_PATH_V2 + "lookup")
|
@POST(NetworkConstants.URI_IDENTITY_PATH_V2 + "lookup")
|
||||||
fun lookup(@Body body: IdentityLookUpParams): Call<IdentityLookUpResponse>
|
suspend fun lookup(@Body body: IdentityLookUpParams): IdentityLookUpResponse
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a session to change the bind status of an email to an identity server
|
* Create a session to change the bind status of an email to an identity server
|
||||||
|
@ -75,7 +74,7 @@ internal interface IdentityAPI {
|
||||||
* @return the sid
|
* @return the sid
|
||||||
*/
|
*/
|
||||||
@POST(NetworkConstants.URI_IDENTITY_PATH_V2 + "validate/email/requestToken")
|
@POST(NetworkConstants.URI_IDENTITY_PATH_V2 + "validate/email/requestToken")
|
||||||
fun requestTokenToBindEmail(@Body body: IdentityRequestTokenForEmailBody): Call<IdentityRequestTokenResponse>
|
suspend fun requestTokenToBindEmail(@Body body: IdentityRequestTokenForEmailBody): IdentityRequestTokenResponse
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a session to change the bind status of an phone number to an identity server
|
* Create a session to change the bind status of an phone number to an identity server
|
||||||
|
@ -85,7 +84,7 @@ internal interface IdentityAPI {
|
||||||
* @return the sid
|
* @return the sid
|
||||||
*/
|
*/
|
||||||
@POST(NetworkConstants.URI_IDENTITY_PATH_V2 + "validate/msisdn/requestToken")
|
@POST(NetworkConstants.URI_IDENTITY_PATH_V2 + "validate/msisdn/requestToken")
|
||||||
fun requestTokenToBindMsisdn(@Body body: IdentityRequestTokenForMsisdnBody): Call<IdentityRequestTokenResponse>
|
suspend fun requestTokenToBindMsisdn(@Body body: IdentityRequestTokenForMsisdnBody): IdentityRequestTokenResponse
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate ownership of an email address, or a phone number.
|
* Validate ownership of an email address, or a phone number.
|
||||||
|
@ -94,6 +93,6 @@ internal interface IdentityAPI {
|
||||||
* - https://matrix.org/docs/spec/identity_service/latest#post-matrix-identity-v2-validate-email-submittoken
|
* - https://matrix.org/docs/spec/identity_service/latest#post-matrix-identity-v2-validate-email-submittoken
|
||||||
*/
|
*/
|
||||||
@POST(NetworkConstants.URI_IDENTITY_PATH_V2 + "validate/{medium}/submitToken")
|
@POST(NetworkConstants.URI_IDENTITY_PATH_V2 + "validate/{medium}/submitToken")
|
||||||
fun submitToken(@Path("medium") medium: String,
|
suspend fun submitToken(@Path("medium") medium: String,
|
||||||
@Body body: IdentityRequestOwnershipParams): Call<SuccessResult>
|
@Body body: IdentityRequestOwnershipParams): SuccessResult
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@ package org.matrix.android.sdk.internal.session.identity
|
||||||
import org.matrix.android.sdk.internal.network.NetworkConstants
|
import org.matrix.android.sdk.internal.network.NetworkConstants
|
||||||
import org.matrix.android.sdk.internal.session.identity.model.IdentityRegisterResponse
|
import org.matrix.android.sdk.internal.session.identity.model.IdentityRegisterResponse
|
||||||
import org.matrix.android.sdk.internal.session.openid.RequestOpenIdTokenResponse
|
import org.matrix.android.sdk.internal.session.openid.RequestOpenIdTokenResponse
|
||||||
import retrofit2.Call
|
|
||||||
import retrofit2.http.Body
|
import retrofit2.http.Body
|
||||||
import retrofit2.http.GET
|
import retrofit2.http.GET
|
||||||
import retrofit2.http.POST
|
import retrofit2.http.POST
|
||||||
|
@ -40,18 +39,18 @@ internal interface IdentityAuthAPI {
|
||||||
* @return 200 in case of success
|
* @return 200 in case of success
|
||||||
*/
|
*/
|
||||||
@GET(NetworkConstants.URI_IDENTITY_PREFIX_PATH)
|
@GET(NetworkConstants.URI_IDENTITY_PREFIX_PATH)
|
||||||
fun ping(): Call<Unit>
|
suspend fun ping()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ping v1 will be used to check outdated Identity server
|
* Ping v1 will be used to check outdated Identity server
|
||||||
*/
|
*/
|
||||||
@GET("_matrix/identity/api/v1")
|
@GET("_matrix/identity/api/v1")
|
||||||
fun pingV1(): Call<Unit>
|
suspend fun pingV1()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exchanges an OpenID token from the homeserver for an access token to access the identity server.
|
* Exchanges an OpenID token from the homeserver for an access token to access the identity server.
|
||||||
* The request body is the same as the values returned by /openid/request_token in the Client-Server API.
|
* The request body is the same as the values returned by /openid/request_token in the Client-Server API.
|
||||||
*/
|
*/
|
||||||
@POST(NetworkConstants.URI_IDENTITY_PATH_V2 + "account/register")
|
@POST(NetworkConstants.URI_IDENTITY_PATH_V2 + "account/register")
|
||||||
fun register(@Body openIdToken: RequestOpenIdTokenResponse): Call<IdentityRegisterResponse>
|
suspend fun register(@Body openIdToken: RequestOpenIdTokenResponse): IdentityRegisterResponse
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,7 @@ internal class DefaultIdentityBulkLookupTask @Inject constructor(
|
||||||
return try {
|
return try {
|
||||||
LookUpData(hashedAddresses,
|
LookUpData(hashedAddresses,
|
||||||
executeRequest(null) {
|
executeRequest(null) {
|
||||||
apiCall = identityAPI.lookup(IdentityLookUpParams(
|
identityAPI.lookup(IdentityLookUpParams(
|
||||||
hashedAddresses,
|
hashedAddresses,
|
||||||
IdentityHashDetailResponse.ALGORITHM_SHA256,
|
IdentityHashDetailResponse.ALGORITHM_SHA256,
|
||||||
hashDetailResponse.pepper
|
hashDetailResponse.pepper
|
||||||
|
@ -126,7 +126,7 @@ internal class DefaultIdentityBulkLookupTask @Inject constructor(
|
||||||
|
|
||||||
private suspend fun fetchHashDetails(identityAPI: IdentityAPI): IdentityHashDetailResponse {
|
private suspend fun fetchHashDetails(identityAPI: IdentityAPI): IdentityHashDetailResponse {
|
||||||
return executeRequest(null) {
|
return executeRequest(null) {
|
||||||
apiCall = identityAPI.hashDetails()
|
identityAPI.hashDetails()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,8 +42,8 @@ internal class DefaultIdentityDisconnectTask @Inject constructor(
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
executeRequest<Unit>(null) {
|
executeRequest(null) {
|
||||||
apiCall = identityAPI.logout()
|
identityAPI.logout()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,14 +33,14 @@ internal class DefaultIdentityPingTask @Inject constructor() : IdentityPingTask
|
||||||
|
|
||||||
override suspend fun execute(params: IdentityPingTask.Params) {
|
override suspend fun execute(params: IdentityPingTask.Params) {
|
||||||
try {
|
try {
|
||||||
executeRequest<Unit>(null) {
|
executeRequest(null) {
|
||||||
apiCall = params.identityAuthAPI.ping()
|
params.identityAuthAPI.ping()
|
||||||
}
|
}
|
||||||
} catch (throwable: Throwable) {
|
} catch (throwable: Throwable) {
|
||||||
if (throwable is Failure.ServerError && throwable.httpCode == HttpsURLConnection.HTTP_NOT_FOUND /* 404 */) {
|
if (throwable is Failure.ServerError && throwable.httpCode == HttpsURLConnection.HTTP_NOT_FOUND /* 404 */) {
|
||||||
// Check if API v1 is available
|
// Check if API v1 is available
|
||||||
executeRequest<Unit>(null) {
|
executeRequest(null) {
|
||||||
apiCall = params.identityAuthAPI.pingV1()
|
params.identityAuthAPI.pingV1()
|
||||||
}
|
}
|
||||||
// API V1 is responding, but not V2 -> Outdated
|
// API V1 is responding, but not V2 -> Outdated
|
||||||
throw IdentityServiceError.OutdatedIdentityServer
|
throw IdentityServiceError.OutdatedIdentityServer
|
||||||
|
|
|
@ -33,7 +33,7 @@ internal class DefaultIdentityRegisterTask @Inject constructor() : IdentityRegis
|
||||||
|
|
||||||
override suspend fun execute(params: IdentityRegisterTask.Params): IdentityRegisterResponse {
|
override suspend fun execute(params: IdentityRegisterTask.Params): IdentityRegisterResponse {
|
||||||
return executeRequest(null) {
|
return executeRequest(null) {
|
||||||
apiCall = params.identityAuthAPI.register(params.openIdTokenResponse)
|
params.identityAuthAPI.register(params.openIdTokenResponse)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,6 @@ import org.matrix.android.sdk.internal.session.identity.data.IdentityPendingBind
|
||||||
import org.matrix.android.sdk.internal.session.identity.data.IdentityStore
|
import org.matrix.android.sdk.internal.session.identity.data.IdentityStore
|
||||||
import org.matrix.android.sdk.internal.session.identity.model.IdentityRequestTokenForEmailBody
|
import org.matrix.android.sdk.internal.session.identity.model.IdentityRequestTokenForEmailBody
|
||||||
import org.matrix.android.sdk.internal.session.identity.model.IdentityRequestTokenForMsisdnBody
|
import org.matrix.android.sdk.internal.session.identity.model.IdentityRequestTokenForMsisdnBody
|
||||||
import org.matrix.android.sdk.internal.session.identity.model.IdentityRequestTokenResponse
|
|
||||||
import org.matrix.android.sdk.internal.task.Task
|
import org.matrix.android.sdk.internal.task.Task
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -56,8 +55,8 @@ internal class DefaultIdentityRequestTokenForBindingTask @Inject constructor(
|
||||||
val clientSecret = identityPendingBinding?.clientSecret ?: UUID.randomUUID().toString()
|
val clientSecret = identityPendingBinding?.clientSecret ?: UUID.randomUUID().toString()
|
||||||
val sendAttempt = identityPendingBinding?.sendAttempt?.inc() ?: 1
|
val sendAttempt = identityPendingBinding?.sendAttempt?.inc() ?: 1
|
||||||
|
|
||||||
val tokenResponse = executeRequest<IdentityRequestTokenResponse>(null) {
|
val tokenResponse = executeRequest(null) {
|
||||||
apiCall = when (params.threePid) {
|
when (params.threePid) {
|
||||||
is ThreePid.Email -> identityAPI.requestTokenToBindEmail(IdentityRequestTokenForEmailBody(
|
is ThreePid.Email -> identityAPI.requestTokenToBindEmail(IdentityRequestTokenForEmailBody(
|
||||||
clientSecret = clientSecret,
|
clientSecret = clientSecret,
|
||||||
sendAttempt = sendAttempt,
|
sendAttempt = sendAttempt,
|
||||||
|
|
|
@ -19,7 +19,6 @@ package org.matrix.android.sdk.internal.session.identity
|
||||||
import org.matrix.android.sdk.api.session.identity.IdentityServiceError
|
import org.matrix.android.sdk.api.session.identity.IdentityServiceError
|
||||||
import org.matrix.android.sdk.api.session.identity.ThreePid
|
import org.matrix.android.sdk.api.session.identity.ThreePid
|
||||||
import org.matrix.android.sdk.api.session.identity.toMedium
|
import org.matrix.android.sdk.api.session.identity.toMedium
|
||||||
import org.matrix.android.sdk.internal.auth.registration.SuccessResult
|
|
||||||
import org.matrix.android.sdk.internal.di.UserId
|
import org.matrix.android.sdk.internal.di.UserId
|
||||||
import org.matrix.android.sdk.internal.network.executeRequest
|
import org.matrix.android.sdk.internal.network.executeRequest
|
||||||
import org.matrix.android.sdk.internal.session.identity.data.IdentityStore
|
import org.matrix.android.sdk.internal.session.identity.data.IdentityStore
|
||||||
|
@ -44,8 +43,8 @@ internal class DefaultIdentitySubmitTokenForBindingTask @Inject constructor(
|
||||||
val identityAPI = getIdentityApiAndEnsureTerms(identityApiProvider, userId)
|
val identityAPI = getIdentityApiAndEnsureTerms(identityApiProvider, userId)
|
||||||
val identityPendingBinding = identityStore.getPendingBinding(params.threePid) ?: throw IdentityServiceError.NoCurrentBindingError
|
val identityPendingBinding = identityStore.getPendingBinding(params.threePid) ?: throw IdentityServiceError.NoCurrentBindingError
|
||||||
|
|
||||||
val tokenResponse = executeRequest<SuccessResult>(null) {
|
val tokenResponse = executeRequest(null) {
|
||||||
apiCall = identityAPI.submitToken(
|
identityAPI.submitToken(
|
||||||
params.threePid.toMedium(),
|
params.threePid.toMedium(),
|
||||||
IdentityRequestOwnershipParams(
|
IdentityRequestOwnershipParams(
|
||||||
clientSecret = identityPendingBinding.clientSecret,
|
clientSecret = identityPendingBinding.clientSecret,
|
||||||
|
|
|
@ -18,14 +18,13 @@ package org.matrix.android.sdk.internal.session.identity
|
||||||
|
|
||||||
import org.matrix.android.sdk.api.session.identity.IdentityServiceError
|
import org.matrix.android.sdk.api.session.identity.IdentityServiceError
|
||||||
import org.matrix.android.sdk.internal.network.executeRequest
|
import org.matrix.android.sdk.internal.network.executeRequest
|
||||||
import org.matrix.android.sdk.internal.session.identity.model.IdentityAccountResponse
|
|
||||||
|
|
||||||
internal suspend fun getIdentityApiAndEnsureTerms(identityApiProvider: IdentityApiProvider, userId: String): IdentityAPI {
|
internal suspend fun getIdentityApiAndEnsureTerms(identityApiProvider: IdentityApiProvider, userId: String): IdentityAPI {
|
||||||
val identityAPI = identityApiProvider.identityApi ?: throw IdentityServiceError.NoIdentityServerConfigured
|
val identityAPI = identityApiProvider.identityApi ?: throw IdentityServiceError.NoIdentityServerConfigured
|
||||||
|
|
||||||
// Always check that we have access to the service (regarding terms)
|
// Always check that we have access to the service (regarding terms)
|
||||||
val identityAccountResponse = executeRequest<IdentityAccountResponse>(null) {
|
val identityAccountResponse = executeRequest(null) {
|
||||||
apiCall = identityAPI.getAccount()
|
identityAPI.getAccount()
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(userId == identityAccountResponse.userId)
|
assert(userId == identityAccountResponse.userId)
|
||||||
|
|
|
@ -65,8 +65,8 @@ internal class DefaultGetPreviewUrlTask @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun doRequest(url: String, timestamp: Long?): PreviewUrlData {
|
private suspend fun doRequest(url: String, timestamp: Long?): PreviewUrlData {
|
||||||
return executeRequest<JsonDict>(globalErrorReceiver) {
|
return executeRequest(globalErrorReceiver) {
|
||||||
apiCall = mediaAPI.getPreviewUrlData(url, timestamp)
|
mediaAPI.getPreviewUrlData(url, timestamp)
|
||||||
}
|
}
|
||||||
.toPreviewUrlData(url)
|
.toPreviewUrlData(url)
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ internal class DefaultGetRawPreviewUrlTask @Inject constructor(
|
||||||
|
|
||||||
override suspend fun execute(params: GetRawPreviewUrlTask.Params): JsonDict {
|
override suspend fun execute(params: GetRawPreviewUrlTask.Params): JsonDict {
|
||||||
return executeRequest(globalErrorReceiver) {
|
return executeRequest(globalErrorReceiver) {
|
||||||
apiCall = mediaAPI.getPreviewUrlData(params.url, params.timestamp)
|
mediaAPI.getPreviewUrlData(params.url, params.timestamp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@ package org.matrix.android.sdk.internal.session.media
|
||||||
|
|
||||||
import org.matrix.android.sdk.api.util.JsonDict
|
import org.matrix.android.sdk.api.util.JsonDict
|
||||||
import org.matrix.android.sdk.internal.network.NetworkConstants
|
import org.matrix.android.sdk.internal.network.NetworkConstants
|
||||||
import retrofit2.Call
|
|
||||||
import retrofit2.http.GET
|
import retrofit2.http.GET
|
||||||
import retrofit2.http.Query
|
import retrofit2.http.Query
|
||||||
|
|
||||||
|
@ -28,7 +27,7 @@ internal interface MediaAPI {
|
||||||
* Ref: https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-media-r0-config
|
* Ref: https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-media-r0-config
|
||||||
*/
|
*/
|
||||||
@GET(NetworkConstants.URI_API_MEDIA_PREFIX_PATH_R0 + "config")
|
@GET(NetworkConstants.URI_API_MEDIA_PREFIX_PATH_R0 + "config")
|
||||||
fun getMediaConfig(): Call<GetMediaConfigResult>
|
suspend fun getMediaConfig(): GetMediaConfigResult
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get information about a URL for the client. Typically this is called when a client
|
* Get information about a URL for the client. Typically this is called when a client
|
||||||
|
@ -39,5 +38,5 @@ internal interface MediaAPI {
|
||||||
* if it does not have the requested version available.
|
* if it does not have the requested version available.
|
||||||
*/
|
*/
|
||||||
@GET(NetworkConstants.URI_API_MEDIA_PREFIX_PATH_R0 + "preview_url")
|
@GET(NetworkConstants.URI_API_MEDIA_PREFIX_PATH_R0 + "preview_url")
|
||||||
fun getPreviewUrlData(@Query("url") url: String, @Query("ts") ts: Long?): Call<JsonDict>
|
suspend fun getPreviewUrlData(@Query("url") url: String, @Query("ts") ts: Long?): JsonDict
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ internal class DefaultGetOpenIdTokenTask @Inject constructor(
|
||||||
|
|
||||||
override suspend fun execute(params: Unit): RequestOpenIdTokenResponse {
|
override suspend fun execute(params: Unit): RequestOpenIdTokenResponse {
|
||||||
return executeRequest(globalErrorReceiver) {
|
return executeRequest(globalErrorReceiver) {
|
||||||
apiCall = openIdAPI.openIdToken(userId)
|
openIdAPI.openIdToken(userId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@ package org.matrix.android.sdk.internal.session.openid
|
||||||
|
|
||||||
import org.matrix.android.sdk.api.util.JsonDict
|
import org.matrix.android.sdk.api.util.JsonDict
|
||||||
import org.matrix.android.sdk.internal.network.NetworkConstants
|
import org.matrix.android.sdk.internal.network.NetworkConstants
|
||||||
import retrofit2.Call
|
|
||||||
import retrofit2.http.Body
|
import retrofit2.http.Body
|
||||||
import retrofit2.http.POST
|
import retrofit2.http.POST
|
||||||
import retrofit2.http.Path
|
import retrofit2.http.Path
|
||||||
|
@ -34,6 +33,6 @@ internal interface OpenIdAPI {
|
||||||
* @param userId the user id
|
* @param userId the user id
|
||||||
*/
|
*/
|
||||||
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "user/{userId}/openid/request_token")
|
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "user/{userId}/openid/request_token")
|
||||||
fun openIdToken(@Path("userId") userId: String,
|
suspend fun openIdToken(@Path("userId") userId: String,
|
||||||
@Body body: JsonDict = emptyMap()): Call<RequestOpenIdTokenResponse>
|
@Body body: JsonDict = emptyMap()): RequestOpenIdTokenResponse
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,13 +50,14 @@ internal class DefaultAddThreePidTask @Inject constructor(
|
||||||
val clientSecret = UUID.randomUUID().toString()
|
val clientSecret = UUID.randomUUID().toString()
|
||||||
val sendAttempt = 1
|
val sendAttempt = 1
|
||||||
|
|
||||||
val result = executeRequest<AddEmailResponse>(globalErrorReceiver) {
|
val body = AddEmailBody(
|
||||||
val body = AddEmailBody(
|
clientSecret = clientSecret,
|
||||||
clientSecret = clientSecret,
|
email = threePid.email,
|
||||||
email = threePid.email,
|
sendAttempt = sendAttempt
|
||||||
sendAttempt = sendAttempt
|
)
|
||||||
)
|
|
||||||
apiCall = profileAPI.addEmail(body)
|
val result = executeRequest(globalErrorReceiver) {
|
||||||
|
profileAPI.addEmail(body)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store as a pending three pid
|
// Store as a pending three pid
|
||||||
|
@ -84,14 +85,15 @@ internal class DefaultAddThreePidTask @Inject constructor(
|
||||||
val countryCode = parsedNumber.countryCode
|
val countryCode = parsedNumber.countryCode
|
||||||
val country = phoneNumberUtil.getRegionCodeForCountryCode(countryCode)
|
val country = phoneNumberUtil.getRegionCodeForCountryCode(countryCode)
|
||||||
|
|
||||||
val result = executeRequest<AddMsisdnResponse>(globalErrorReceiver) {
|
val body = AddMsisdnBody(
|
||||||
val body = AddMsisdnBody(
|
clientSecret = clientSecret,
|
||||||
clientSecret = clientSecret,
|
country = country,
|
||||||
country = country,
|
phoneNumber = parsedNumber.nationalNumber.toString(),
|
||||||
phoneNumber = parsedNumber.nationalNumber.toString(),
|
sendAttempt = sendAttempt
|
||||||
sendAttempt = sendAttempt
|
)
|
||||||
)
|
|
||||||
apiCall = profileAPI.addMsisdn(body)
|
val result = executeRequest(globalErrorReceiver) {
|
||||||
|
profileAPI.addMsisdn(body)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store as a pending three pid
|
// Store as a pending three pid
|
||||||
|
|
|
@ -43,8 +43,8 @@ internal class DefaultBindThreePidsTask @Inject constructor(private val profileA
|
||||||
val identityServerAccessToken = accessTokenProvider.getToken() ?: throw IdentityServiceError.NoIdentityServerConfigured
|
val identityServerAccessToken = accessTokenProvider.getToken() ?: throw IdentityServiceError.NoIdentityServerConfigured
|
||||||
val identityPendingBinding = identityStore.getPendingBinding(params.threePid) ?: throw IdentityServiceError.NoCurrentBindingError
|
val identityPendingBinding = identityStore.getPendingBinding(params.threePid) ?: throw IdentityServiceError.NoCurrentBindingError
|
||||||
|
|
||||||
executeRequest<Unit>(globalErrorReceiver) {
|
executeRequest(globalErrorReceiver) {
|
||||||
apiCall = profileAPI.bindThreePid(
|
profileAPI.bindThreePid(
|
||||||
BindThreePidBody(
|
BindThreePidBody(
|
||||||
clientSecret = identityPendingBinding.clientSecret,
|
clientSecret = identityPendingBinding.clientSecret,
|
||||||
identityServerUrlWithoutProtocol = identityServerUrlWithoutProtocol,
|
identityServerUrlWithoutProtocol = identityServerUrlWithoutProtocol,
|
||||||
|
|
|
@ -34,12 +34,12 @@ internal class DefaultDeleteThreePidTask @Inject constructor(
|
||||||
private val globalErrorReceiver: GlobalErrorReceiver) : DeleteThreePidTask() {
|
private val globalErrorReceiver: GlobalErrorReceiver) : DeleteThreePidTask() {
|
||||||
|
|
||||||
override suspend fun execute(params: Params) {
|
override suspend fun execute(params: Params) {
|
||||||
executeRequest<DeleteThreePidResponse>(globalErrorReceiver) {
|
val body = DeleteThreePidBody(
|
||||||
val body = DeleteThreePidBody(
|
medium = params.threePid.toMedium(),
|
||||||
medium = params.threePid.toMedium(),
|
address = params.threePid.value
|
||||||
address = params.threePid.value
|
)
|
||||||
)
|
executeRequest(globalErrorReceiver) {
|
||||||
apiCall = profileAPI.deleteThreePid(body)
|
profileAPI.deleteThreePid(body)
|
||||||
}
|
}
|
||||||
|
|
||||||
// We do not really care about the result for the moment
|
// We do not really care about the result for the moment
|
||||||
|
|
|
@ -61,13 +61,13 @@ internal class DefaultFinalizeAddingThreePidTask @Inject constructor(
|
||||||
?: throw IllegalArgumentException("unknown threepid")
|
?: throw IllegalArgumentException("unknown threepid")
|
||||||
|
|
||||||
try {
|
try {
|
||||||
executeRequest<Unit>(globalErrorReceiver) {
|
executeRequest(globalErrorReceiver) {
|
||||||
val body = FinalizeAddThreePidBody(
|
val body = FinalizeAddThreePidBody(
|
||||||
clientSecret = pendingThreePids.clientSecret,
|
clientSecret = pendingThreePids.clientSecret,
|
||||||
sid = pendingThreePids.sid,
|
sid = pendingThreePids.sid,
|
||||||
auth = params.userAuthParam?.asMap()
|
auth = params.userAuthParam?.asMap()
|
||||||
)
|
)
|
||||||
apiCall = profileAPI.finalizeAddThreePid(body)
|
profileAPI.finalizeAddThreePid(body)
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
} catch (throwable: Throwable) {
|
} catch (throwable: Throwable) {
|
||||||
|
|
|
@ -34,7 +34,7 @@ internal class DefaultGetProfileInfoTask @Inject constructor(private val profile
|
||||||
|
|
||||||
override suspend fun execute(params: Params): JsonDict {
|
override suspend fun execute(params: Params): JsonDict {
|
||||||
return executeRequest(globalErrorReceiver) {
|
return executeRequest(globalErrorReceiver) {
|
||||||
apiCall = profileAPI.getProfile(params.userId)
|
profileAPI.getProfile(params.userId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@ import org.matrix.android.sdk.api.util.JsonDict
|
||||||
import org.matrix.android.sdk.internal.auth.registration.SuccessResult
|
import org.matrix.android.sdk.internal.auth.registration.SuccessResult
|
||||||
import org.matrix.android.sdk.internal.auth.registration.ValidationCodeBody
|
import org.matrix.android.sdk.internal.auth.registration.ValidationCodeBody
|
||||||
import org.matrix.android.sdk.internal.network.NetworkConstants
|
import org.matrix.android.sdk.internal.network.NetworkConstants
|
||||||
import retrofit2.Call
|
|
||||||
import retrofit2.http.Body
|
import retrofit2.http.Body
|
||||||
import retrofit2.http.GET
|
import retrofit2.http.GET
|
||||||
import retrofit2.http.POST
|
import retrofit2.http.POST
|
||||||
|
@ -37,70 +36,70 @@ internal interface ProfileAPI {
|
||||||
* @param userId the user id to fetch profile info
|
* @param userId the user id to fetch profile info
|
||||||
*/
|
*/
|
||||||
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "profile/{userId}")
|
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "profile/{userId}")
|
||||||
fun getProfile(@Path("userId") userId: String): Call<JsonDict>
|
suspend fun getProfile(@Path("userId") userId: String): JsonDict
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List all 3PIDs linked to the Matrix user account.
|
* List all 3PIDs linked to the Matrix user account.
|
||||||
*/
|
*/
|
||||||
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "account/3pid")
|
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "account/3pid")
|
||||||
fun getThreePIDs(): Call<AccountThreePidsResponse>
|
suspend fun getThreePIDs(): AccountThreePidsResponse
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change user display name
|
* Change user display name
|
||||||
*/
|
*/
|
||||||
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "profile/{userId}/displayname")
|
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "profile/{userId}/displayname")
|
||||||
fun setDisplayName(@Path("userId") userId: String,
|
suspend fun setDisplayName(@Path("userId") userId: String,
|
||||||
@Body body: SetDisplayNameBody): Call<Unit>
|
@Body body: SetDisplayNameBody)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change user avatar url.
|
* Change user avatar url.
|
||||||
*/
|
*/
|
||||||
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "profile/{userId}/avatar_url")
|
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "profile/{userId}/avatar_url")
|
||||||
fun setAvatarUrl(@Path("userId") userId: String,
|
suspend fun setAvatarUrl(@Path("userId") userId: String,
|
||||||
@Body body: SetAvatarUrlBody): Call<Unit>
|
@Body body: SetAvatarUrlBody)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bind a threePid
|
* Bind a threePid
|
||||||
* Ref: https://matrix.org/docs/spec/client_server/latest#post-matrix-client-r0-account-3pid-bind
|
* Ref: https://matrix.org/docs/spec/client_server/latest#post-matrix-client-r0-account-3pid-bind
|
||||||
*/
|
*/
|
||||||
@POST(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "account/3pid/bind")
|
@POST(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "account/3pid/bind")
|
||||||
fun bindThreePid(@Body body: BindThreePidBody): Call<Unit>
|
suspend fun bindThreePid(@Body body: BindThreePidBody)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unbind a threePid
|
* Unbind a threePid
|
||||||
* Ref: https://matrix.org/docs/spec/client_server/latest#post-matrix-client-r0-account-3pid-unbind
|
* Ref: https://matrix.org/docs/spec/client_server/latest#post-matrix-client-r0-account-3pid-unbind
|
||||||
*/
|
*/
|
||||||
@POST(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "account/3pid/unbind")
|
@POST(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "account/3pid/unbind")
|
||||||
fun unbindThreePid(@Body body: UnbindThreePidBody): Call<UnbindThreePidResponse>
|
suspend fun unbindThreePid(@Body body: UnbindThreePidBody): UnbindThreePidResponse
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ref: https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-account-3pid-email-requesttoken
|
* Ref: https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-account-3pid-email-requesttoken
|
||||||
*/
|
*/
|
||||||
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "account/3pid/email/requestToken")
|
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "account/3pid/email/requestToken")
|
||||||
fun addEmail(@Body body: AddEmailBody): Call<AddEmailResponse>
|
suspend fun addEmail(@Body body: AddEmailBody): AddEmailResponse
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ref: https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-account-3pid-msisdn-requesttoken
|
* Ref: https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-account-3pid-msisdn-requesttoken
|
||||||
*/
|
*/
|
||||||
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "account/3pid/msisdn/requestToken")
|
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "account/3pid/msisdn/requestToken")
|
||||||
fun addMsisdn(@Body body: AddMsisdnBody): Call<AddMsisdnResponse>
|
suspend fun addMsisdn(@Body body: AddMsisdnBody): AddMsisdnResponse
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate Msisdn code (same model than for Identity server API)
|
* Validate Msisdn code (same model than for Identity server API)
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
fun validateMsisdn(@Url url: String,
|
suspend fun validateMsisdn(@Url url: String,
|
||||||
@Body params: ValidationCodeBody): Call<SuccessResult>
|
@Body params: ValidationCodeBody): SuccessResult
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ref: https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-account-3pid-add
|
* Ref: https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-account-3pid-add
|
||||||
*/
|
*/
|
||||||
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "account/3pid/add")
|
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "account/3pid/add")
|
||||||
fun finalizeAddThreePid(@Body body: FinalizeAddThreePidBody): Call<Unit>
|
suspend fun finalizeAddThreePid(@Body body: FinalizeAddThreePidBody)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ref: https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-account-3pid-delete
|
* Ref: https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-account-3pid-delete
|
||||||
*/
|
*/
|
||||||
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "account/3pid/delete")
|
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "account/3pid/delete")
|
||||||
fun deleteThreePid(@Body body: DeleteThreePidBody): Call<DeleteThreePidResponse>
|
suspend fun deleteThreePid(@Body body: DeleteThreePidBody): DeleteThreePidResponse
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,8 +33,8 @@ internal class DefaultRefreshUserThreePidsTask @Inject constructor(private val p
|
||||||
private val globalErrorReceiver: GlobalErrorReceiver) : RefreshUserThreePidsTask() {
|
private val globalErrorReceiver: GlobalErrorReceiver) : RefreshUserThreePidsTask() {
|
||||||
|
|
||||||
override suspend fun execute(params: Unit) {
|
override suspend fun execute(params: Unit) {
|
||||||
val accountThreePidsResponse = executeRequest<AccountThreePidsResponse>(globalErrorReceiver) {
|
val accountThreePidsResponse = executeRequest(globalErrorReceiver) {
|
||||||
apiCall = profileAPI.getThreePIDs()
|
profileAPI.getThreePIDs()
|
||||||
}
|
}
|
||||||
|
|
||||||
Timber.d("Get ${accountThreePidsResponse.threePids?.size} threePids")
|
Timber.d("Get ${accountThreePidsResponse.threePids?.size} threePids")
|
||||||
|
|
|
@ -33,11 +33,11 @@ internal class DefaultSetAvatarUrlTask @Inject constructor(
|
||||||
private val globalErrorReceiver: GlobalErrorReceiver) : SetAvatarUrlTask() {
|
private val globalErrorReceiver: GlobalErrorReceiver) : SetAvatarUrlTask() {
|
||||||
|
|
||||||
override suspend fun execute(params: Params) {
|
override suspend fun execute(params: Params) {
|
||||||
|
val body = SetAvatarUrlBody(
|
||||||
|
avatarUrl = params.newAvatarUrl
|
||||||
|
)
|
||||||
return executeRequest(globalErrorReceiver) {
|
return executeRequest(globalErrorReceiver) {
|
||||||
val body = SetAvatarUrlBody(
|
profileAPI.setAvatarUrl(params.userId, body)
|
||||||
avatarUrl = params.newAvatarUrl
|
|
||||||
)
|
|
||||||
apiCall = profileAPI.setAvatarUrl(params.userId, body)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,11 +33,11 @@ internal class DefaultSetDisplayNameTask @Inject constructor(
|
||||||
private val globalErrorReceiver: GlobalErrorReceiver) : SetDisplayNameTask() {
|
private val globalErrorReceiver: GlobalErrorReceiver) : SetDisplayNameTask() {
|
||||||
|
|
||||||
override suspend fun execute(params: Params) {
|
override suspend fun execute(params: Params) {
|
||||||
|
val body = SetDisplayNameBody(
|
||||||
|
displayName = params.newDisplayName
|
||||||
|
)
|
||||||
return executeRequest(globalErrorReceiver) {
|
return executeRequest(globalErrorReceiver) {
|
||||||
val body = SetDisplayNameBody(
|
profileAPI.setDisplayName(params.userId, body)
|
||||||
displayName = params.newDisplayName
|
|
||||||
)
|
|
||||||
apiCall = profileAPI.setDisplayName(params.userId, body)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,8 +39,8 @@ internal class DefaultUnbindThreePidsTask @Inject constructor(private val profil
|
||||||
val identityServerUrlWithoutProtocol = identityStore.getIdentityServerUrlWithoutProtocol()
|
val identityServerUrlWithoutProtocol = identityStore.getIdentityServerUrlWithoutProtocol()
|
||||||
?: throw IdentityServiceError.NoIdentityServerConfigured
|
?: throw IdentityServiceError.NoIdentityServerConfigured
|
||||||
|
|
||||||
return executeRequest<UnbindThreePidResponse>(globalErrorReceiver) {
|
return executeRequest(globalErrorReceiver) {
|
||||||
apiCall = profileAPI.unbindThreePid(
|
profileAPI.unbindThreePid(
|
||||||
UnbindThreePidBody(
|
UnbindThreePidBody(
|
||||||
identityServerUrlWithoutProtocol,
|
identityServerUrlWithoutProtocol,
|
||||||
params.threePid.toMedium(),
|
params.threePid.toMedium(),
|
||||||
|
|
|
@ -19,7 +19,6 @@ package org.matrix.android.sdk.internal.session.profile
|
||||||
import com.zhuinden.monarchy.Monarchy
|
import com.zhuinden.monarchy.Monarchy
|
||||||
import org.matrix.android.sdk.api.failure.Failure
|
import org.matrix.android.sdk.api.failure.Failure
|
||||||
import org.matrix.android.sdk.api.session.identity.ThreePid
|
import org.matrix.android.sdk.api.session.identity.ThreePid
|
||||||
import org.matrix.android.sdk.internal.auth.registration.SuccessResult
|
|
||||||
import org.matrix.android.sdk.internal.auth.registration.ValidationCodeBody
|
import org.matrix.android.sdk.internal.auth.registration.ValidationCodeBody
|
||||||
import org.matrix.android.sdk.internal.database.model.PendingThreePidEntity
|
import org.matrix.android.sdk.internal.database.model.PendingThreePidEntity
|
||||||
import org.matrix.android.sdk.internal.di.SessionDatabase
|
import org.matrix.android.sdk.internal.di.SessionDatabase
|
||||||
|
@ -58,8 +57,8 @@ internal class DefaultValidateSmsCodeTask @Inject constructor(
|
||||||
sid = pendingThreePids.sid,
|
sid = pendingThreePids.sid,
|
||||||
code = params.code
|
code = params.code
|
||||||
)
|
)
|
||||||
val result = executeRequest<SuccessResult>(globalErrorReceiver) {
|
val result = executeRequest(globalErrorReceiver) {
|
||||||
apiCall = profileAPI.validateMsisdn(url, body)
|
profileAPI.validateMsisdn(url, body)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!result.isSuccess()) {
|
if (!result.isSuccess()) {
|
||||||
|
|
|
@ -81,8 +81,8 @@ internal class AddHttpPusherWorker(context: Context, params: WorkerParameters)
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun setPusher(pusher: JsonPusher) {
|
private suspend fun setPusher(pusher: JsonPusher) {
|
||||||
executeRequest<Unit>(globalErrorReceiver) {
|
executeRequest(globalErrorReceiver) {
|
||||||
apiCall = pushersAPI.setPusher(pusher)
|
pushersAPI.setPusher(pusher)
|
||||||
}
|
}
|
||||||
monarchy.awaitTransaction { realm ->
|
monarchy.awaitTransaction { realm ->
|
||||||
val echo = PusherEntity.where(realm, pusher.pushKey).findFirst()
|
val echo = PusherEntity.where(realm, pusher.pushKey).findFirst()
|
||||||
|
|
|
@ -36,7 +36,7 @@ internal class DefaultAddPushRuleTask @Inject constructor(
|
||||||
|
|
||||||
override suspend fun execute(params: AddPushRuleTask.Params) {
|
override suspend fun execute(params: AddPushRuleTask.Params) {
|
||||||
return executeRequest(globalErrorReceiver) {
|
return executeRequest(globalErrorReceiver) {
|
||||||
apiCall = pushRulesApi.addRule(params.kind.value, params.pushRule.ruleId, params.pushRule)
|
pushRulesApi.addRule(params.kind.value, params.pushRule.ruleId, params.pushRule)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
*/
|
*/
|
||||||
package org.matrix.android.sdk.internal.session.pushers
|
package org.matrix.android.sdk.internal.session.pushers
|
||||||
|
|
||||||
import org.matrix.android.sdk.api.pushrules.rest.GetPushRulesResponse
|
|
||||||
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
|
||||||
|
@ -35,8 +34,8 @@ internal class DefaultGetPushRulesTask @Inject constructor(
|
||||||
) : GetPushRulesTask {
|
) : GetPushRulesTask {
|
||||||
|
|
||||||
override suspend fun execute(params: GetPushRulesTask.Params) {
|
override suspend fun execute(params: GetPushRulesTask.Params) {
|
||||||
val response = executeRequest<GetPushRulesResponse>(globalErrorReceiver) {
|
val response = executeRequest(globalErrorReceiver) {
|
||||||
apiCall = pushRulesApi.getAllRules()
|
pushRulesApi.getAllRules()
|
||||||
}
|
}
|
||||||
|
|
||||||
savePushRulesTask.execute(SavePushRulesTask.Params(response))
|
savePushRulesTask.execute(SavePushRulesTask.Params(response))
|
||||||
|
|
|
@ -36,8 +36,8 @@ internal class DefaultGetPushersTask @Inject constructor(
|
||||||
) : GetPushersTask {
|
) : GetPushersTask {
|
||||||
|
|
||||||
override suspend fun execute(params: Unit) {
|
override suspend fun execute(params: Unit) {
|
||||||
val response = executeRequest<GetPushersResponse>(globalErrorReceiver) {
|
val response = executeRequest(globalErrorReceiver) {
|
||||||
apiCall = pushersAPI.getPushers()
|
pushersAPI.getPushers()
|
||||||
}
|
}
|
||||||
monarchy.awaitTransaction { realm ->
|
monarchy.awaitTransaction { realm ->
|
||||||
// clear existings?
|
// clear existings?
|
||||||
|
|
|
@ -18,7 +18,6 @@ package org.matrix.android.sdk.internal.session.pushers
|
||||||
import org.matrix.android.sdk.api.pushrules.rest.GetPushRulesResponse
|
import org.matrix.android.sdk.api.pushrules.rest.GetPushRulesResponse
|
||||||
import org.matrix.android.sdk.api.pushrules.rest.PushRule
|
import org.matrix.android.sdk.api.pushrules.rest.PushRule
|
||||||
import org.matrix.android.sdk.internal.network.NetworkConstants
|
import org.matrix.android.sdk.internal.network.NetworkConstants
|
||||||
import retrofit2.Call
|
|
||||||
import retrofit2.http.Body
|
import retrofit2.http.Body
|
||||||
import retrofit2.http.DELETE
|
import retrofit2.http.DELETE
|
||||||
import retrofit2.http.GET
|
import retrofit2.http.GET
|
||||||
|
@ -30,7 +29,7 @@ internal interface PushRulesApi {
|
||||||
* Get all push rules
|
* Get all push rules
|
||||||
*/
|
*/
|
||||||
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "pushrules/")
|
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "pushrules/")
|
||||||
fun getAllRules(): Call<GetPushRulesResponse>
|
suspend fun getAllRules(): GetPushRulesResponse
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the ruleID enable status
|
* Update the ruleID enable status
|
||||||
|
@ -40,10 +39,9 @@ internal interface PushRulesApi {
|
||||||
* @param enable the new enable status
|
* @param enable the new enable status
|
||||||
*/
|
*/
|
||||||
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "pushrules/global/{kind}/{ruleId}/enabled")
|
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "pushrules/global/{kind}/{ruleId}/enabled")
|
||||||
fun updateEnableRuleStatus(@Path("kind") kind: String,
|
suspend fun updateEnableRuleStatus(@Path("kind") kind: String,
|
||||||
@Path("ruleId") ruleId: String,
|
@Path("ruleId") ruleId: String,
|
||||||
@Body enable: Boolean?)
|
@Body enable: Boolean?)
|
||||||
: Call<Unit>
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the ruleID action
|
* Update the ruleID action
|
||||||
|
@ -54,10 +52,9 @@ internal interface PushRulesApi {
|
||||||
* @param actions the actions
|
* @param actions the actions
|
||||||
*/
|
*/
|
||||||
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "pushrules/global/{kind}/{ruleId}/actions")
|
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "pushrules/global/{kind}/{ruleId}/actions")
|
||||||
fun updateRuleActions(@Path("kind") kind: String,
|
suspend fun updateRuleActions(@Path("kind") kind: String,
|
||||||
@Path("ruleId") ruleId: String,
|
@Path("ruleId") ruleId: String,
|
||||||
@Body actions: Any)
|
@Body actions: Any)
|
||||||
: Call<Unit>
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a rule
|
* Delete a rule
|
||||||
|
@ -66,9 +63,8 @@ internal interface PushRulesApi {
|
||||||
* @param ruleId the ruleId
|
* @param ruleId the ruleId
|
||||||
*/
|
*/
|
||||||
@DELETE(NetworkConstants.URI_API_PREFIX_PATH_R0 + "pushrules/global/{kind}/{ruleId}")
|
@DELETE(NetworkConstants.URI_API_PREFIX_PATH_R0 + "pushrules/global/{kind}/{ruleId}")
|
||||||
fun deleteRule(@Path("kind") kind: String,
|
suspend fun deleteRule(@Path("kind") kind: String,
|
||||||
@Path("ruleId") ruleId: String)
|
@Path("ruleId") ruleId: String)
|
||||||
: Call<Unit>
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the ruleID enable status
|
* Add the ruleID enable status
|
||||||
|
@ -78,8 +74,7 @@ internal interface PushRulesApi {
|
||||||
* @param rule the rule to add.
|
* @param rule the rule to add.
|
||||||
*/
|
*/
|
||||||
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "pushrules/global/{kind}/{ruleId}")
|
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "pushrules/global/{kind}/{ruleId}")
|
||||||
fun addRule(@Path("kind") kind: String,
|
suspend fun addRule(@Path("kind") kind: String,
|
||||||
@Path("ruleId") ruleId: String,
|
@Path("ruleId") ruleId: String,
|
||||||
@Body rule: PushRule)
|
@Body rule: PushRule)
|
||||||
: Call<Unit>
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
package org.matrix.android.sdk.internal.session.pushers
|
package org.matrix.android.sdk.internal.session.pushers
|
||||||
|
|
||||||
import org.matrix.android.sdk.internal.network.NetworkConstants
|
import org.matrix.android.sdk.internal.network.NetworkConstants
|
||||||
import retrofit2.Call
|
|
||||||
import retrofit2.http.Body
|
import retrofit2.http.Body
|
||||||
import retrofit2.http.GET
|
import retrofit2.http.GET
|
||||||
import retrofit2.http.POST
|
import retrofit2.http.POST
|
||||||
|
@ -29,7 +28,7 @@ internal interface PushersAPI {
|
||||||
* Ref: https://matrix.org/docs/spec/client_server/latest#get-matrix-client-r0-pushers
|
* Ref: https://matrix.org/docs/spec/client_server/latest#get-matrix-client-r0-pushers
|
||||||
*/
|
*/
|
||||||
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "pushers")
|
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "pushers")
|
||||||
fun getPushers(): Call<GetPushersResponse>
|
suspend fun getPushers(): GetPushersResponse
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This endpoint allows the creation, modification and deletion of pushers for this user ID.
|
* This endpoint allows the creation, modification and deletion of pushers for this user ID.
|
||||||
|
@ -38,5 +37,5 @@ internal interface PushersAPI {
|
||||||
* Ref: https://matrix.org/docs/spec/client_server/latest#post-matrix-client-r0-pushers-set
|
* Ref: https://matrix.org/docs/spec/client_server/latest#post-matrix-client-r0-pushers-set
|
||||||
*/
|
*/
|
||||||
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "pushers/set")
|
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "pushers/set")
|
||||||
fun setPusher(@Body jsonPusher: JsonPusher): Call<Unit>
|
suspend fun setPusher(@Body jsonPusher: JsonPusher)
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ internal class DefaultRemovePushRuleTask @Inject constructor(
|
||||||
|
|
||||||
override suspend fun execute(params: RemovePushRuleTask.Params) {
|
override suspend fun execute(params: RemovePushRuleTask.Params) {
|
||||||
return executeRequest(globalErrorReceiver) {
|
return executeRequest(globalErrorReceiver) {
|
||||||
apiCall = pushRulesApi.deleteRule(params.kind.value, params.pushRule.ruleId)
|
pushRulesApi.deleteRule(params.kind.value, params.pushRule.ruleId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,8 +62,8 @@ internal class DefaultRemovePusherTask @Inject constructor(
|
||||||
data = JsonPusherData(existing.data.url, existing.data.format),
|
data = JsonPusherData(existing.data.url, existing.data.format),
|
||||||
append = false
|
append = false
|
||||||
)
|
)
|
||||||
executeRequest<Unit>(globalErrorReceiver) {
|
executeRequest(globalErrorReceiver) {
|
||||||
apiCall = pushersAPI.setPusher(deleteBody)
|
pushersAPI.setPusher(deleteBody)
|
||||||
}
|
}
|
||||||
monarchy.awaitTransaction {
|
monarchy.awaitTransaction {
|
||||||
PusherEntity.where(it, params.pushKey).findFirst()?.deleteFromRealm()
|
PusherEntity.where(it, params.pushKey).findFirst()?.deleteFromRealm()
|
||||||
|
|
|
@ -38,8 +38,8 @@ internal class DefaultUpdatePushRuleActionsTask @Inject constructor(
|
||||||
override suspend fun execute(params: UpdatePushRuleActionsTask.Params) {
|
override suspend fun execute(params: UpdatePushRuleActionsTask.Params) {
|
||||||
if (params.oldPushRule.enabled != params.newPushRule.enabled) {
|
if (params.oldPushRule.enabled != params.newPushRule.enabled) {
|
||||||
// First change enabled state
|
// First change enabled state
|
||||||
executeRequest<Unit>(globalErrorReceiver) {
|
executeRequest(globalErrorReceiver) {
|
||||||
apiCall = pushRulesApi.updateEnableRuleStatus(params.kind.value, params.newPushRule.ruleId, params.newPushRule.enabled)
|
pushRulesApi.updateEnableRuleStatus(params.kind.value, params.newPushRule.ruleId, params.newPushRule.enabled)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,8 +47,8 @@ internal class DefaultUpdatePushRuleActionsTask @Inject constructor(
|
||||||
// Also ensure the actions are up to date
|
// Also ensure the actions are up to date
|
||||||
val body = mapOf("actions" to params.newPushRule.actions)
|
val body = mapOf("actions" to params.newPushRule.actions)
|
||||||
|
|
||||||
executeRequest<Unit>(globalErrorReceiver) {
|
executeRequest(globalErrorReceiver) {
|
||||||
apiCall = pushRulesApi.updateRuleActions(params.kind.value, params.newPushRule.ruleId, body)
|
pushRulesApi.updateRuleActions(params.kind.value, params.newPushRule.ruleId, body)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ internal class DefaultUpdatePushRuleEnableStatusTask @Inject constructor(
|
||||||
|
|
||||||
override suspend fun execute(params: UpdatePushRuleEnableStatusTask.Params) {
|
override suspend fun execute(params: UpdatePushRuleEnableStatusTask.Params) {
|
||||||
return executeRequest(globalErrorReceiver) {
|
return executeRequest(globalErrorReceiver) {
|
||||||
apiCall = pushRulesApi.updateEnableRuleStatus(params.kind.value, params.pushRule.ruleId, params.enabled)
|
pushRulesApi.updateEnableRuleStatus(params.kind.value, params.pushRule.ruleId, params.enabled)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
package org.matrix.android.sdk.internal.session.pushers.gateway
|
package org.matrix.android.sdk.internal.session.pushers.gateway
|
||||||
|
|
||||||
import org.matrix.android.sdk.internal.network.NetworkConstants
|
import org.matrix.android.sdk.internal.network.NetworkConstants
|
||||||
import retrofit2.Call
|
|
||||||
import retrofit2.http.Body
|
import retrofit2.http.Body
|
||||||
import retrofit2.http.POST
|
import retrofit2.http.POST
|
||||||
|
|
||||||
|
@ -27,5 +26,5 @@ internal interface PushGatewayAPI {
|
||||||
* Ref: https://matrix.org/docs/spec/push_gateway/r0.1.1#post-matrix-push-v1-notify
|
* Ref: https://matrix.org/docs/spec/push_gateway/r0.1.1#post-matrix-push-v1-notify
|
||||||
*/
|
*/
|
||||||
@POST(NetworkConstants.URI_PUSH_GATEWAY_PREFIX_PATH + "notify")
|
@POST(NetworkConstants.URI_PUSH_GATEWAY_PREFIX_PATH + "notify")
|
||||||
fun notify(@Body body: PushGatewayNotifyBody): Call<PushGatewayNotifyResponse>
|
suspend fun notify(@Body body: PushGatewayNotifyBody): PushGatewayNotifyResponse
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,8 +45,8 @@ internal class DefaultPushGatewayNotifyTask @Inject constructor(
|
||||||
)
|
)
|
||||||
.create(PushGatewayAPI::class.java)
|
.create(PushGatewayAPI::class.java)
|
||||||
|
|
||||||
val response = executeRequest<PushGatewayNotifyResponse>(null) {
|
val response = executeRequest(null) {
|
||||||
apiCall = sygnalApi.notify(
|
sygnalApi.notify(
|
||||||
PushGatewayNotifyBody(
|
PushGatewayNotifyBody(
|
||||||
PushGatewayNotification(
|
PushGatewayNotification(
|
||||||
eventId = params.eventId,
|
eventId = params.eventId,
|
||||||
|
|
|
@ -38,7 +38,6 @@ import org.matrix.android.sdk.internal.session.room.tags.TagBody
|
||||||
import org.matrix.android.sdk.internal.session.room.timeline.EventContextResponse
|
import org.matrix.android.sdk.internal.session.room.timeline.EventContextResponse
|
||||||
import org.matrix.android.sdk.internal.session.room.timeline.PaginationResponse
|
import org.matrix.android.sdk.internal.session.room.timeline.PaginationResponse
|
||||||
import org.matrix.android.sdk.internal.session.room.typing.TypingBody
|
import org.matrix.android.sdk.internal.session.room.typing.TypingBody
|
||||||
import retrofit2.Call
|
|
||||||
import retrofit2.http.Body
|
import retrofit2.http.Body
|
||||||
import retrofit2.http.DELETE
|
import retrofit2.http.DELETE
|
||||||
import retrofit2.http.GET
|
import retrofit2.http.GET
|
||||||
|
@ -57,9 +56,9 @@ internal interface RoomAPI {
|
||||||
* Ref: https://matrix.org/docs/spec/client_server/r0.4.0.html#post-matrix-client-r0-publicrooms
|
* Ref: https://matrix.org/docs/spec/client_server/r0.4.0.html#post-matrix-client-r0-publicrooms
|
||||||
*/
|
*/
|
||||||
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "publicRooms")
|
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "publicRooms")
|
||||||
fun publicRooms(@Query("server") server: String?,
|
suspend fun publicRooms(@Query("server") server: String?,
|
||||||
@Body publicRoomsParams: PublicRoomsParams
|
@Body publicRoomsParams: PublicRoomsParams
|
||||||
): Call<PublicRoomsResponse>
|
): PublicRoomsResponse
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a room.
|
* Create a room.
|
||||||
|
@ -71,7 +70,7 @@ internal interface RoomAPI {
|
||||||
*/
|
*/
|
||||||
@Headers("CONNECT_TIMEOUT:60000", "READ_TIMEOUT:60000", "WRITE_TIMEOUT:60000")
|
@Headers("CONNECT_TIMEOUT:60000", "READ_TIMEOUT:60000", "WRITE_TIMEOUT:60000")
|
||||||
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "createRoom")
|
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "createRoom")
|
||||||
fun createRoom(@Body param: CreateRoomBody): Call<CreateRoomResponse>
|
suspend fun createRoom(@Body param: CreateRoomBody): CreateRoomResponse
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of messages starting from a reference.
|
* Get a list of messages starting from a reference.
|
||||||
|
@ -83,12 +82,12 @@ internal interface RoomAPI {
|
||||||
* @param filter A JSON RoomEventFilter to filter returned events with. Optional.
|
* @param filter A JSON RoomEventFilter to filter returned events with. Optional.
|
||||||
*/
|
*/
|
||||||
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/messages")
|
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/messages")
|
||||||
fun getRoomMessagesFrom(@Path("roomId") roomId: String,
|
suspend fun getRoomMessagesFrom(@Path("roomId") roomId: String,
|
||||||
@Query("from") from: String,
|
@Query("from") from: String,
|
||||||
@Query("dir") dir: String,
|
@Query("dir") dir: String,
|
||||||
@Query("limit") limit: Int,
|
@Query("limit") limit: Int,
|
||||||
@Query("filter") filter: String?
|
@Query("filter") filter: String?
|
||||||
): Call<PaginationResponse>
|
): PaginationResponse
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all members of a room
|
* Get all members of a room
|
||||||
|
@ -99,11 +98,11 @@ internal interface RoomAPI {
|
||||||
* @param notMembership to exclude one type of membership (optional)
|
* @param notMembership to exclude one type of membership (optional)
|
||||||
*/
|
*/
|
||||||
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/members")
|
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/members")
|
||||||
fun getMembers(@Path("roomId") roomId: String,
|
suspend fun getMembers(@Path("roomId") roomId: String,
|
||||||
@Query("at") syncToken: String?,
|
@Query("at") syncToken: String?,
|
||||||
@Query("membership") membership: Membership?,
|
@Query("membership") membership: Membership?,
|
||||||
@Query("not_membership") notMembership: Membership?
|
@Query("not_membership") notMembership: Membership?
|
||||||
): Call<RoomMembersResponse>
|
): RoomMembersResponse
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send an event to a room.
|
* Send an event to a room.
|
||||||
|
@ -114,11 +113,11 @@ internal interface RoomAPI {
|
||||||
* @param content the event content
|
* @param content the event content
|
||||||
*/
|
*/
|
||||||
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/send/{eventType}/{txId}")
|
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/send/{eventType}/{txId}")
|
||||||
fun send(@Path("txId") txId: String,
|
suspend fun send(@Path("txId") txId: String,
|
||||||
@Path("roomId") roomId: String,
|
@Path("roomId") roomId: String,
|
||||||
@Path("eventType") eventType: String,
|
@Path("eventType") eventType: String,
|
||||||
@Body content: Content?
|
@Body content: Content?
|
||||||
): Call<SendResponse>
|
): SendResponse
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the context surrounding an event.
|
* Get the context surrounding an event.
|
||||||
|
@ -129,10 +128,10 @@ internal interface RoomAPI {
|
||||||
* @param filter A JSON RoomEventFilter to filter returned events with. Optional.
|
* @param filter A JSON RoomEventFilter to filter returned events with. Optional.
|
||||||
*/
|
*/
|
||||||
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/context/{eventId}")
|
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/context/{eventId}")
|
||||||
fun getContextOfEvent(@Path("roomId") roomId: String,
|
suspend fun getContextOfEvent(@Path("roomId") roomId: String,
|
||||||
@Path("eventId") eventId: String,
|
@Path("eventId") eventId: String,
|
||||||
@Query("limit") limit: Int,
|
@Query("limit") limit: Int,
|
||||||
@Query("filter") filter: String? = null): Call<EventContextResponse>
|
@Query("filter") filter: String? = null): EventContextResponse
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve an event from its room id / events id
|
* Retrieve an event from its room id / events id
|
||||||
|
@ -141,8 +140,8 @@ internal interface RoomAPI {
|
||||||
* @param eventId the event Id
|
* @param eventId the event Id
|
||||||
*/
|
*/
|
||||||
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/event/{eventId}")
|
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/event/{eventId}")
|
||||||
fun getEvent(@Path("roomId") roomId: String,
|
suspend fun getEvent(@Path("roomId") roomId: String,
|
||||||
@Path("eventId") eventId: String): Call<Event>
|
@Path("eventId") eventId: String): Event
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send read markers.
|
* Send read markers.
|
||||||
|
@ -151,8 +150,8 @@ internal interface RoomAPI {
|
||||||
* @param markers the read markers
|
* @param markers the read markers
|
||||||
*/
|
*/
|
||||||
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/read_markers")
|
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/read_markers")
|
||||||
fun sendReadMarker(@Path("roomId") roomId: String,
|
suspend fun sendReadMarker(@Path("roomId") roomId: String,
|
||||||
@Body markers: Map<String, String>): Call<Unit>
|
@Body markers: Map<String, String>)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invite a user to the given room.
|
* Invite a user to the given room.
|
||||||
|
@ -162,8 +161,8 @@ internal interface RoomAPI {
|
||||||
* @param body a object that just contains a user id
|
* @param body a object that just contains a user id
|
||||||
*/
|
*/
|
||||||
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/invite")
|
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/invite")
|
||||||
fun invite(@Path("roomId") roomId: String,
|
suspend fun invite(@Path("roomId") roomId: String,
|
||||||
@Body body: InviteBody): Call<Unit>
|
@Body body: InviteBody)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invite a user to a room, using a ThreePid
|
* Invite a user to a room, using a ThreePid
|
||||||
|
@ -171,8 +170,8 @@ internal interface RoomAPI {
|
||||||
* @param roomId Required. The room identifier (not alias) to which to invite the user.
|
* @param roomId Required. The room identifier (not alias) to which to invite the user.
|
||||||
*/
|
*/
|
||||||
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/invite")
|
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/invite")
|
||||||
fun invite3pid(@Path("roomId") roomId: String,
|
suspend fun invite3pid(@Path("roomId") roomId: String,
|
||||||
@Body body: ThreePidInviteBody): Call<Unit>
|
@Body body: ThreePidInviteBody)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a generic state event
|
* Send a generic state event
|
||||||
|
@ -182,9 +181,9 @@ internal interface RoomAPI {
|
||||||
* @param params the request parameters
|
* @param params the request parameters
|
||||||
*/
|
*/
|
||||||
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/state/{state_event_type}")
|
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/state/{state_event_type}")
|
||||||
fun sendStateEvent(@Path("roomId") roomId: String,
|
suspend fun sendStateEvent(@Path("roomId") roomId: String,
|
||||||
@Path("state_event_type") stateEventType: String,
|
@Path("state_event_type") stateEventType: String,
|
||||||
@Body params: JsonDict): Call<Unit>
|
@Body params: JsonDict)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a generic state event
|
* Send a generic state event
|
||||||
|
@ -195,17 +194,17 @@ internal interface RoomAPI {
|
||||||
* @param params the request parameters
|
* @param params the request parameters
|
||||||
*/
|
*/
|
||||||
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/state/{state_event_type}/{state_key}")
|
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/state/{state_event_type}/{state_key}")
|
||||||
fun sendStateEvent(@Path("roomId") roomId: String,
|
suspend fun sendStateEvent(@Path("roomId") roomId: String,
|
||||||
@Path("state_event_type") stateEventType: String,
|
@Path("state_event_type") stateEventType: String,
|
||||||
@Path("state_key") stateKey: String,
|
@Path("state_key") stateKey: String,
|
||||||
@Body params: JsonDict): Call<Unit>
|
@Body params: JsonDict)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get state events of a room
|
* Get state events of a room
|
||||||
* Ref: https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-rooms-roomid-state
|
* Ref: https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-rooms-roomid-state
|
||||||
*/
|
*/
|
||||||
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/state")
|
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/state")
|
||||||
fun getRoomState(@Path("roomId") roomId: String) : Call<List<Event>>
|
suspend fun getRoomState(@Path("roomId") roomId: String): List<Event>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a relation event to a room.
|
* Send a relation event to a room.
|
||||||
|
@ -216,12 +215,12 @@ internal interface RoomAPI {
|
||||||
* @param content the event content
|
* @param content the event content
|
||||||
*/
|
*/
|
||||||
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/send_relation/{parent_id}/{relation_type}/{event_type}")
|
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/send_relation/{parent_id}/{relation_type}/{event_type}")
|
||||||
fun sendRelation(@Path("roomId") roomId: String,
|
suspend fun sendRelation(@Path("roomId") roomId: String,
|
||||||
@Path("parent_id") parentId: String,
|
@Path("parent_id") parentId: String,
|
||||||
@Path("relation_type") relationType: String,
|
@Path("relation_type") relationType: String,
|
||||||
@Path("event_type") eventType: String,
|
@Path("event_type") eventType: String,
|
||||||
@Body content: Content?
|
@Body content: Content?
|
||||||
): Call<SendResponse>
|
): SendResponse
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Paginate relations for event based in normal topological order
|
* Paginate relations for event based in normal topological order
|
||||||
|
@ -230,11 +229,11 @@ internal interface RoomAPI {
|
||||||
* @param eventType filter for this event type
|
* @param eventType filter for this event type
|
||||||
*/
|
*/
|
||||||
@GET(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "rooms/{roomId}/relations/{eventId}/{relationType}/{eventType}")
|
@GET(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "rooms/{roomId}/relations/{eventId}/{relationType}/{eventType}")
|
||||||
fun getRelations(@Path("roomId") roomId: String,
|
suspend fun getRelations(@Path("roomId") roomId: String,
|
||||||
@Path("eventId") eventId: String,
|
@Path("eventId") eventId: String,
|
||||||
@Path("relationType") relationType: String,
|
@Path("relationType") relationType: String,
|
||||||
@Path("eventType") eventType: String
|
@Path("eventType") eventType: String
|
||||||
): Call<RelationsResponse>
|
): RelationsResponse
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Join the given room.
|
* Join the given room.
|
||||||
|
@ -244,9 +243,9 @@ internal interface RoomAPI {
|
||||||
* @param params the request body
|
* @param params the request body
|
||||||
*/
|
*/
|
||||||
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "join/{roomIdOrAlias}")
|
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "join/{roomIdOrAlias}")
|
||||||
fun join(@Path("roomIdOrAlias") roomIdOrAlias: String,
|
suspend fun join(@Path("roomIdOrAlias") roomIdOrAlias: String,
|
||||||
@Query("server_name") viaServers: List<String>,
|
@Query("server_name") viaServers: List<String>,
|
||||||
@Body params: Map<String, String?>): Call<JoinRoomResponse>
|
@Body params: Map<String, String?>): JoinRoomResponse
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Leave the given room.
|
* Leave the given room.
|
||||||
|
@ -255,8 +254,8 @@ internal interface RoomAPI {
|
||||||
* @param params the request body
|
* @param params the request body
|
||||||
*/
|
*/
|
||||||
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/leave")
|
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/leave")
|
||||||
fun leave(@Path("roomId") roomId: String,
|
suspend fun leave(@Path("roomId") roomId: String,
|
||||||
@Body params: Map<String, String?>): Call<Unit>
|
@Body params: Map<String, String?>)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ban a user from the given room.
|
* Ban a user from the given room.
|
||||||
|
@ -265,8 +264,8 @@ internal interface RoomAPI {
|
||||||
* @param userIdAndReason the banned user object (userId and reason for ban)
|
* @param userIdAndReason the banned user object (userId and reason for ban)
|
||||||
*/
|
*/
|
||||||
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/ban")
|
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/ban")
|
||||||
fun ban(@Path("roomId") roomId: String,
|
suspend fun ban(@Path("roomId") roomId: String,
|
||||||
@Body userIdAndReason: UserIdAndReason): Call<Unit>
|
@Body userIdAndReason: UserIdAndReason)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* unban a user from the given room.
|
* unban a user from the given room.
|
||||||
|
@ -275,8 +274,8 @@ internal interface RoomAPI {
|
||||||
* @param userIdAndReason the unbanned user object (userId and reason for unban)
|
* @param userIdAndReason the unbanned user object (userId and reason for unban)
|
||||||
*/
|
*/
|
||||||
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/unban")
|
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/unban")
|
||||||
fun unban(@Path("roomId") roomId: String,
|
suspend fun unban(@Path("roomId") roomId: String,
|
||||||
@Body userIdAndReason: UserIdAndReason): Call<Unit>
|
@Body userIdAndReason: UserIdAndReason)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Kick a user from the given room.
|
* Kick a user from the given room.
|
||||||
|
@ -285,8 +284,8 @@ internal interface RoomAPI {
|
||||||
* @param userIdAndReason the kicked user object (userId and reason for kicking)
|
* @param userIdAndReason the kicked user object (userId and reason for kicking)
|
||||||
*/
|
*/
|
||||||
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/kick")
|
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/kick")
|
||||||
fun kick(@Path("roomId") roomId: String,
|
suspend fun kick(@Path("roomId") roomId: String,
|
||||||
@Body userIdAndReason: UserIdAndReason): Call<Unit>
|
@Body userIdAndReason: UserIdAndReason)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Strips all information out of an event which isn't critical to the integrity of the server-side representation of the room.
|
* Strips all information out of an event which isn't critical to the integrity of the server-side representation of the room.
|
||||||
|
@ -299,12 +298,12 @@ internal interface RoomAPI {
|
||||||
* @param reason json containing reason key {"reason": "Indecent material"}
|
* @param reason json containing reason key {"reason": "Indecent material"}
|
||||||
*/
|
*/
|
||||||
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/redact/{eventId}/{txnId}")
|
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/redact/{eventId}/{txnId}")
|
||||||
fun redactEvent(
|
suspend fun redactEvent(
|
||||||
@Path("txnId") txId: String,
|
@Path("txnId") txId: String,
|
||||||
@Path("roomId") roomId: String,
|
@Path("roomId") roomId: String,
|
||||||
@Path("eventId") eventId: String,
|
@Path("eventId") eventId: String,
|
||||||
@Body reason: Map<String, String>
|
@Body reason: Map<String, String>
|
||||||
): Call<SendResponse>
|
): SendResponse
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reports an event as inappropriate to the server, which may then notify the appropriate people.
|
* Reports an event as inappropriate to the server, which may then notify the appropriate people.
|
||||||
|
@ -314,24 +313,24 @@ internal interface RoomAPI {
|
||||||
* @param body body containing score and reason
|
* @param body body containing score and reason
|
||||||
*/
|
*/
|
||||||
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/report/{eventId}")
|
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/report/{eventId}")
|
||||||
fun reportContent(@Path("roomId") roomId: String,
|
suspend fun reportContent(@Path("roomId") roomId: String,
|
||||||
@Path("eventId") eventId: String,
|
@Path("eventId") eventId: String,
|
||||||
@Body body: ReportContentBody): Call<Unit>
|
@Body body: ReportContentBody)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of aliases maintained by the local server for the given room.
|
* Get a list of aliases maintained by the local server for the given room.
|
||||||
* Ref: https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-rooms-roomid-aliases
|
* Ref: https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-rooms-roomid-aliases
|
||||||
*/
|
*/
|
||||||
@GET(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "org.matrix.msc2432/rooms/{roomId}/aliases")
|
@GET(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "org.matrix.msc2432/rooms/{roomId}/aliases")
|
||||||
fun getAliases(@Path("roomId") roomId: String): Call<GetAliasesResponse>
|
suspend fun getAliases(@Path("roomId") roomId: String): GetAliasesResponse
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inform that the user is starting to type or has stopped typing
|
* Inform that the user is starting to type or has stopped typing
|
||||||
*/
|
*/
|
||||||
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/typing/{userId}")
|
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/typing/{userId}")
|
||||||
fun sendTypingState(@Path("roomId") roomId: String,
|
suspend fun sendTypingState(@Path("roomId") roomId: String,
|
||||||
@Path("userId") userId: String,
|
@Path("userId") userId: String,
|
||||||
@Body body: TypingBody): Call<Unit>
|
@Body body: TypingBody)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Room tagging
|
* Room tagging
|
||||||
|
@ -341,16 +340,16 @@ internal interface RoomAPI {
|
||||||
* Add a tag to a room.
|
* Add a tag to a room.
|
||||||
*/
|
*/
|
||||||
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "user/{userId}/rooms/{roomId}/tags/{tag}")
|
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "user/{userId}/rooms/{roomId}/tags/{tag}")
|
||||||
fun putTag(@Path("userId") userId: String,
|
suspend fun putTag(@Path("userId") userId: String,
|
||||||
@Path("roomId") roomId: String,
|
@Path("roomId") roomId: String,
|
||||||
@Path("tag") tag: String,
|
@Path("tag") tag: String,
|
||||||
@Body body: TagBody): Call<Unit>
|
@Body body: TagBody)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a tag from a room.
|
* Delete a tag from a room.
|
||||||
*/
|
*/
|
||||||
@DELETE(NetworkConstants.URI_API_PREFIX_PATH_R0 + "user/{userId}/rooms/{roomId}/tags/{tag}")
|
@DELETE(NetworkConstants.URI_API_PREFIX_PATH_R0 + "user/{userId}/rooms/{roomId}/tags/{tag}")
|
||||||
fun deleteTag(@Path("userId") userId: String,
|
suspend fun deleteTag(@Path("userId") userId: String,
|
||||||
@Path("roomId") roomId: String,
|
@Path("roomId") roomId: String,
|
||||||
@Path("tag") tag: String): Call<Unit>
|
@Path("tag") tag: String)
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,8 +45,8 @@ internal class DefaultAddRoomAliasTask @Inject constructor(
|
||||||
override suspend fun execute(params: AddRoomAliasTask.Params) {
|
override suspend fun execute(params: AddRoomAliasTask.Params) {
|
||||||
aliasAvailabilityChecker.check(params.aliasLocalPart)
|
aliasAvailabilityChecker.check(params.aliasLocalPart)
|
||||||
|
|
||||||
executeRequest<Unit>(globalErrorReceiver) {
|
executeRequest(globalErrorReceiver) {
|
||||||
apiCall = directoryAPI.addRoomAlias(
|
directoryAPI.addRoomAlias(
|
||||||
roomAlias = params.aliasLocalPart.toFullLocalAlias(userId),
|
roomAlias = params.aliasLocalPart.toFullLocalAlias(userId),
|
||||||
body = AddRoomAliasBody(
|
body = AddRoomAliasBody(
|
||||||
roomId = params.roomId
|
roomId = params.roomId
|
||||||
|
|
|
@ -34,8 +34,8 @@ internal class DefaultDeleteRoomAliasTask @Inject constructor(
|
||||||
) : DeleteRoomAliasTask {
|
) : DeleteRoomAliasTask {
|
||||||
|
|
||||||
override suspend fun execute(params: DeleteRoomAliasTask.Params) {
|
override suspend fun execute(params: DeleteRoomAliasTask.Params) {
|
||||||
executeRequest<Unit>(globalErrorReceiver) {
|
executeRequest(globalErrorReceiver) {
|
||||||
apiCall = directoryAPI.deleteRoomAlias(
|
directoryAPI.deleteRoomAlias(
|
||||||
roomAlias = params.roomAlias
|
roomAlias = params.roomAlias
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,8 +52,8 @@ internal class DefaultGetRoomIdByAliasTask @Inject constructor(
|
||||||
Optional.from(null)
|
Optional.from(null)
|
||||||
} else {
|
} else {
|
||||||
val description = tryOrNull("## Failed to get roomId from alias") {
|
val description = tryOrNull("## Failed to get roomId from alias") {
|
||||||
executeRequest<RoomAliasDescription>(globalErrorReceiver) {
|
executeRequest(globalErrorReceiver) {
|
||||||
apiCall = directoryAPI.getRoomIdByAlias(params.roomAlias)
|
directoryAPI.getRoomIdByAlias(params.roomAlias)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Optional.from(description)
|
Optional.from(description)
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue