diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/CryptoModule.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/CryptoModule.kt index 297979afc7..e114f86a99 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/CryptoModule.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/CryptoModule.kt @@ -71,7 +71,6 @@ import org.matrix.android.sdk.internal.crypto.tasks.DefaultSendToDeviceTask import org.matrix.android.sdk.internal.crypto.tasks.DefaultSendVerificationMessageTask import org.matrix.android.sdk.internal.crypto.tasks.DefaultSetDeviceNameTask import org.matrix.android.sdk.internal.crypto.tasks.DefaultUploadKeysTask -import org.matrix.android.sdk.internal.crypto.tasks.NewDefaultUploadKeysTask import org.matrix.android.sdk.internal.crypto.tasks.DefaultUploadSignaturesTask import org.matrix.android.sdk.internal.crypto.tasks.DefaultUploadSigningKeysTask import org.matrix.android.sdk.internal.crypto.tasks.DeleteDeviceTask @@ -85,7 +84,6 @@ import org.matrix.android.sdk.internal.crypto.tasks.SendToDeviceTask import org.matrix.android.sdk.internal.crypto.tasks.SendVerificationMessageTask import org.matrix.android.sdk.internal.crypto.tasks.SetDeviceNameTask import org.matrix.android.sdk.internal.crypto.tasks.UploadKeysTask -import org.matrix.android.sdk.internal.crypto.tasks.NewUploadKeysTask import org.matrix.android.sdk.internal.crypto.tasks.UploadSignaturesTask import org.matrix.android.sdk.internal.crypto.tasks.UploadSigningKeysTask import org.matrix.android.sdk.internal.database.RealmKeysUtils @@ -177,9 +175,6 @@ internal abstract class CryptoModule { @Binds abstract fun bindUploadKeysTask(task: DefaultUploadKeysTask): UploadKeysTask - @Binds - abstract fun bindNewUploadKeysTask(task: NewDefaultUploadKeysTask): NewUploadKeysTask - @Binds abstract fun bindUploadSigningKeysTask(task: DefaultUploadSigningKeysTask): UploadSigningKeysTask diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DefaultCryptoService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DefaultCryptoService.kt index 52a617053e..73e0c9da2f 100755 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DefaultCryptoService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DefaultCryptoService.kt @@ -88,10 +88,9 @@ import org.matrix.android.sdk.internal.crypto.tasks.DeleteDeviceTask import org.matrix.android.sdk.internal.crypto.tasks.DownloadKeysForUsersTask import org.matrix.android.sdk.internal.crypto.tasks.GetDeviceInfoTask import org.matrix.android.sdk.internal.crypto.tasks.GetDevicesTask -import org.matrix.android.sdk.internal.crypto.tasks.NewUploadKeysTask +import org.matrix.android.sdk.internal.crypto.tasks.UploadKeysTask import org.matrix.android.sdk.internal.crypto.tasks.SetDeviceNameTask import org.matrix.android.sdk.internal.crypto.tasks.SendToDeviceTask -import org.matrix.android.sdk.internal.crypto.tasks.UploadKeysTask import org.matrix.android.sdk.internal.crypto.tasks.ClaimOneTimeKeysForUsersDeviceTask import org.matrix.android.sdk.internal.crypto.verification.DefaultVerificationService import org.matrix.android.sdk.internal.di.DeviceId @@ -168,7 +167,6 @@ internal class DefaultCryptoService @Inject constructor( private val getDeviceInfoTask: GetDeviceInfoTask, private val setDeviceNameTask: SetDeviceNameTask, private val uploadKeysTask: UploadKeysTask, - private val newUploadKeysTask: NewUploadKeysTask, private val loadRoomMembersTask: LoadRoomMembersTask, private val cryptoSessionInfoProvider: CryptoSessionInfoProvider, private val coroutineDispatchers: MatrixCoroutineDispatchers, @@ -890,9 +888,9 @@ internal class DefaultCryptoService @Inject constructor( is Request.KeysUpload -> { Timber.v("HELLO UPLOADING RUSTY KEYS") val body = MoshiProvider.providesMoshi().adapter(Map::class.java).fromJson(outgoingRequest.body)!! - val request = NewUploadKeysTask.Params(body) + val request = UploadKeysTask.Params(body) - val response = newUploadKeysTask.execute(request) + val response = uploadKeysTask.execute(request) val adapter = MoshiProvider.providesMoshi().adapter(KeysUploadResponse::class.java) val json_response = adapter.toJson(response)!! olmMachine!!.markRequestAsSent(outgoingRequest.requestId, RequestType.KEYS_UPLOAD, json_response) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/api/CryptoApi.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/api/CryptoApi.kt index 104cb1e97f..3c02670b9b 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/api/CryptoApi.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/api/CryptoApi.kt @@ -56,21 +56,12 @@ internal interface CryptoApi { @GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "devices/{deviceId}") fun getDeviceInfo(@Path("deviceId") deviceId: String): Call - /** - * Upload device and/or one-time keys. - * Doc: https://matrix.org/docs/spec/client_server/r0.4.0.html#post-matrix-client-r0-keys-upload - * - * @param body the keys to be sent. - */ - @POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "keys/upload") - fun uploadKeys(@Body body: KeysUploadBody): Call - /** * Upload device and one-time keys * @param body the keys to be sent. */ @POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "keys/upload") - fun newUploadKeys(@Body body: JsonDict): Call + fun UploadKeys(@Body body: JsonDict): Call /** * Download device keys. diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/UploadKeysTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/UploadKeysTask.kt index 0dbd87c537..b485de702a 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/UploadKeysTask.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/UploadKeysTask.kt @@ -29,10 +29,7 @@ import javax.inject.Inject internal interface UploadKeysTask : Task { data class Params( - // the device keys to send. - val deviceKeys: DeviceKeys?, - // the one-time keys to send. - val oneTimeKeys: JsonDict? + val body: JsonDict ) } @@ -42,35 +39,10 @@ internal class DefaultUploadKeysTask @Inject constructor( ) : UploadKeysTask { override suspend fun execute(params: UploadKeysTask.Params): KeysUploadResponse { - val body = KeysUploadBody( - deviceKeys = params.deviceKeys, - oneTimeKeys = params.oneTimeKeys - ) - - Timber.i("## Uploading device keys -> $body") - - return executeRequest(globalErrorReceiver) { - apiCall = cryptoApi.uploadKeys(body) - } - } -} - -internal interface NewUploadKeysTask : Task { - data class Params( - val body: JsonDict - ) -} - -internal class NewDefaultUploadKeysTask @Inject constructor( - private val cryptoApi: CryptoApi, - private val globalErrorReceiver: GlobalErrorReceiver -) : NewUploadKeysTask { - - override suspend fun execute(params: NewUploadKeysTask.Params): KeysUploadResponse { Timber.i("## Uploading device keys -> $params.body") return executeRequest(globalErrorReceiver) { - apiCall = cryptoApi.newUploadKeys(params.body) + apiCall = cryptoApi.UploadKeys(params.body) } } }