diff --git a/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/common/CryptoTestHelper.kt b/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/common/CryptoTestHelper.kt index 7368c87252..765fd65db7 100644 --- a/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/common/CryptoTestHelper.kt +++ b/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/common/CryptoTestHelper.kt @@ -340,18 +340,14 @@ class CryptoTestHelper(val mTestHelper: CommonTestHelper) { fun createFakeMegolmBackupAuthData(): MegolmBackupAuthData { return MegolmBackupAuthData( publicKey = "abcdefg", - signatures = HashMap>().apply { - this["something"] = HashMap().apply { - this["ed25519:something"] = "hijklmnop" - } - } + signatures = mapOf("something" to mapOf("ed25519:something" to "hijklmnop")) ) } fun createFakeMegolmBackupCreationInfo(): MegolmBackupCreationInfo { - return MegolmBackupCreationInfo().apply { - algorithm = MXCRYPTO_ALGORITHM_MEGOLM_BACKUP - authData = createFakeMegolmBackupAuthData() - } + return MegolmBackupCreationInfo( + algorithm = MXCRYPTO_ALGORITHM_MEGOLM_BACKUP, + authData = createFakeMegolmBackupAuthData() + ) } } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/auth/data/WellKnown.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/auth/data/WellKnown.kt index 6285e866cc..bdad4702b7 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/auth/data/WellKnown.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/auth/data/WellKnown.kt @@ -46,13 +46,13 @@ import com.squareup.moshi.JsonClass @JsonClass(generateAdapter = true) data class WellKnown( @Json(name = "m.homeserver") - var homeServer: WellKnownBaseConfig? = null, + val homeServer: WellKnownBaseConfig? = null, @Json(name = "m.identity_server") - var identityServer: WellKnownBaseConfig? = null, + val identityServer: WellKnownBaseConfig? = null, @Json(name = "m.integrations") - var integrations: Map? = null + val integrations: Map? = null ) { /** * Returns the list of integration managers proposed diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/create/CreateRoomResponse.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/create/CreateRoomResponse.kt index 29c8cb830d..da54b344a2 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/create/CreateRoomResponse.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/create/CreateRoomResponse.kt @@ -24,7 +24,7 @@ internal data class CreateRoomResponse( /** * Required. The created room's ID. */ - @Json(name = "room_id") var roomId: String + @Json(name = "room_id") val roomId: String ) internal typealias JoinRoomResponse = CreateRoomResponse diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/roomdirectory/PublicRoomsFilter.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/roomdirectory/PublicRoomsFilter.kt index b4de72e41a..c519d054f2 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/roomdirectory/PublicRoomsFilter.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/roomdirectory/PublicRoomsFilter.kt @@ -27,5 +27,5 @@ data class PublicRoomsFilter( * A string to search for in the room metadata, e.g. name, topic, canonical alias etc. (Optional). */ @Json(name = "generic_search_term") - var searchTerm: String? = null + val searchTerm: String? = null ) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/roomdirectory/PublicRoomsParams.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/roomdirectory/PublicRoomsParams.kt index e2af1c3ccb..467968cd2a 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/roomdirectory/PublicRoomsParams.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/roomdirectory/PublicRoomsParams.kt @@ -28,30 +28,30 @@ data class PublicRoomsParams( * Limit the number of results returned. */ @Json(name = "limit") - var limit: Int? = null, + val limit: Int? = null, /** * A pagination token from a previous request, allowing clients to get the next (or previous) batch of rooms. * The direction of pagination is specified solely by which token is supplied, rather than via an explicit flag. */ @Json(name = "since") - var since: String? = null, + val since: String? = null, /** * Filter to apply to the results. */ @Json(name = "filter") - var filter: PublicRoomsFilter? = null, + val filter: PublicRoomsFilter? = null, /** * Whether or not to include all known networks/protocols from application services on the homeserver. Defaults to false. */ @Json(name = "include_all_networks") - var includeAllNetworks: Boolean = false, + val includeAllNetworks: Boolean = false, /** * The specific third party network/protocol to request from the homeserver. Can only be used if include_all_networks is false. */ @Json(name = "third_party_instance_id") - var thirdPartyInstanceId: String? = null + val thirdPartyInstanceId: String? = null ) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/thirdparty/ThirdPartyProtocol.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/thirdparty/ThirdPartyProtocol.kt index b066cff164..b4ed1f1a8e 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/thirdparty/ThirdPartyProtocol.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/thirdparty/ThirdPartyProtocol.kt @@ -26,7 +26,7 @@ data class ThirdPartyProtocol( * where higher groupings are ordered first. For example, the name of a network should be searched before the nickname of a user. */ @Json(name = "user_fields") - var userFields: List? = null, + val userFields: List? = null, /** * Required. Fields which may be used to identify a third party location. These should be ordered to suggest the way that @@ -34,15 +34,15 @@ data class ThirdPartyProtocol( * searched before the name of a channel. */ @Json(name = "location_fields") - var locationFields: List? = null, + val locationFields: List? = null, /** * Required. A content URI representing an icon for the third party protocol. * - * FIXDOC: This field was not present in legacy Riot, and it is sometimes sent by the server (no not Required?) + * FIXDOC: This field was not present in legacy Riot, and it is sometimes sent by the server (so not Required?) */ @Json(name = "icon") - var icon: String? = null, + val icon: String? = null, /** * Required. The type definitions for the fields defined in the user_fields and location_fields. Each entry in those arrays MUST have an entry here. @@ -51,12 +51,12 @@ data class ThirdPartyProtocol( * May be an empty object if no fields are defined. */ @Json(name = "field_types") - var fieldTypes: Map? = null, + val fieldTypes: Map? = null, /** * Required. A list of objects representing independent instances of configuration. For example, multiple networks on IRC * if multiple are provided by the same application service. */ @Json(name = "instances") - var instances: List? = null + val instances: List? = null ) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/thirdparty/ThirdPartyProtocolInstance.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/thirdparty/ThirdPartyProtocolInstance.kt index 50f92356fb..f5d59f9282 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/thirdparty/ThirdPartyProtocolInstance.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/thirdparty/ThirdPartyProtocolInstance.kt @@ -25,35 +25,35 @@ data class ThirdPartyProtocolInstance( * Required. A human-readable description for the protocol, such as the name. */ @Json(name = "desc") - var desc: String? = null, + val desc: String? = null, /** * An optional content URI representing the protocol. Overrides the one provided at the higher level Protocol object. */ @Json(name = "icon") - var icon: String? = null, + val icon: String? = null, /** * Required. Preset values for fields the client may use to search by. */ @Json(name = "fields") - var fields: Map? = null, + val fields: Map? = null, /** * Required. A unique identifier across all instances. */ @Json(name = "network_id") - var networkId: String? = null, + val networkId: String? = null, /** * FIXDOC Not documented on matrix.org doc */ @Json(name = "instance_id") - var instanceId: String? = null, + val instanceId: String? = null, /** * FIXDOC Not documented on matrix.org doc */ @Json(name = "bot_user_id") - var botUserId: String? = null + val botUserId: String? = null ) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/auth/registration/RegistrationFlowResponse.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/auth/registration/RegistrationFlowResponse.kt index 2d3d25e538..7512454052 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/auth/registration/RegistrationFlowResponse.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/auth/registration/RegistrationFlowResponse.kt @@ -32,20 +32,20 @@ data class RegistrationFlowResponse( * The list of flows. */ @Json(name = "flows") - var flows: List? = null, + val flows: List? = null, /** * The list of stages the client has completed successfully. */ @Json(name = "completed") - var completedStages: List? = null, + val completedStages: List? = null, /** * The session identifier that the client must pass back to the home server, if one is provided, * in subsequent attempts to authenticate in the same API call. */ @Json(name = "session") - var session: String? = null, + val session: String? = null, /** * The information that the client will need to know in order to use a given type of authentication. @@ -53,7 +53,7 @@ data class RegistrationFlowResponse( * For example, the public key of reCAPTCHA stage could be given here. */ @Json(name = "params") - var params: JsonDict? = null + val params: JsonDict? = null /** * WARNING, diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/DefaultCryptoService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/DefaultCryptoService.kt index c4d115b10c..1db774fd2d 100755 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/DefaultCryptoService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/DefaultCryptoService.kt @@ -1021,12 +1021,12 @@ internal class DefaultCryptoService @Inject constructor( return } - val requestBody = RoomKeyRequestBody() - - requestBody.roomId = event.roomId - requestBody.algorithm = wireContent["algorithm"]?.toString() - requestBody.senderKey = wireContent["sender_key"]?.toString() - requestBody.sessionId = wireContent["session_id"]?.toString() + val requestBody = RoomKeyRequestBody( + algorithm = wireContent["algorithm"]?.toString(), + roomId = event.roomId, + senderKey = wireContent["sender_key"]?.toString(), + sessionId = wireContent["session_id"]?.toString() + ) outgoingRoomKeyRequestManager.resendRoomKeyRequest(requestBody) } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/IncomingRoomKeyRequest.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/IncomingRoomKeyRequest.kt index fe1f69f904..93ba5aafe5 100755 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/IncomingRoomKeyRequest.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/IncomingRoomKeyRequest.kt @@ -25,54 +25,54 @@ import im.vector.matrix.android.internal.crypto.model.rest.RoomKeyShareRequest /** * IncomingRoomKeyRequest class defines the incoming room keys request. */ -open class IncomingRoomKeyRequest { - /** - * The user id - */ - var userId: String? = null +data class IncomingRoomKeyRequest( + /** + * The user id + */ + override val userId: String? = null, - /** - * The device id - */ - var deviceId: String? = null + /** + * The device id + */ + override val deviceId: String? = null, - /** - * The request id - */ - var requestId: String? = null + /** + * The request id + */ + override val requestId: String? = null, - /** - * The request body - */ - var requestBody: RoomKeyRequestBody? = null + /** + * The request body + */ + val requestBody: RoomKeyRequestBody? = null, - /** - * The runnable to call to accept to share the keys - */ - @Transient - var share: Runnable? = null + /** + * The runnable to call to accept to share the keys + */ + @Transient + var share: Runnable? = null, - /** - * The runnable to call to ignore the key share request. - */ - @Transient - var ignore: Runnable? = null + /** + * The runnable to call to ignore the key share request. + */ + @Transient + var ignore: Runnable? = null +) : IncomingRoomKeyRequestCommon { + companion object { + /** + * Factory + * + * @param event the event + */ + fun fromEvent(event: Event): IncomingRoomKeyRequest { + val roomKeyShareRequest = event.getClearContent().toModel()!! - /** - * Constructor - * - * @param event the event - */ - constructor(event: Event) { - userId = event.senderId - val roomKeyShareRequest = event.getClearContent().toModel()!! - deviceId = roomKeyShareRequest.requestingDeviceId - requestId = roomKeyShareRequest.requestId - requestBody = if (null != roomKeyShareRequest.body) roomKeyShareRequest.body else RoomKeyRequestBody() + return IncomingRoomKeyRequest( + userId = event.senderId, + deviceId = roomKeyShareRequest.requestingDeviceId, + requestId = roomKeyShareRequest.requestId, + requestBody = roomKeyShareRequest.body ?: RoomKeyRequestBody() + ) + } } - - /** - * Constructor for object creation from crypto store - */ - constructor() } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/IncomingRoomKeyRequestCancellation.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/IncomingRoomKeyRequestCancellation.kt index 0b22a0e28b..a33828505e 100755 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/IncomingRoomKeyRequestCancellation.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/IncomingRoomKeyRequestCancellation.kt @@ -17,13 +17,43 @@ package im.vector.matrix.android.internal.crypto import im.vector.matrix.android.api.session.events.model.Event +import im.vector.matrix.android.api.session.events.model.toModel +import im.vector.matrix.android.internal.crypto.model.rest.RoomKeyShareCancellation /** * IncomingRoomKeyRequestCancellation describes the incoming room key cancellation. */ -class IncomingRoomKeyRequestCancellation(event: Event) : IncomingRoomKeyRequest(event) { +data class IncomingRoomKeyRequestCancellation( + /** + * The user id + */ + override val userId: String? = null, - init { - requestBody = null + /** + * The device id + */ + override val deviceId: String? = null, + + /** + * The request id + */ + override val requestId: String? = null +) : IncomingRoomKeyRequestCommon { + companion object { + + /** + * Factory + * + * @param event the event + */ + fun fromEvent(event: Event): IncomingRoomKeyRequestCancellation { + val roomKeyShareRequestCancellation = event.getClearContent().toModel()!! + + return IncomingRoomKeyRequestCancellation( + userId = event.senderId, + deviceId = roomKeyShareRequestCancellation.requestingDeviceId, + requestId = roomKeyShareRequestCancellation.requestId + ) + } } } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/IncomingRoomKeyRequestCommon.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/IncomingRoomKeyRequestCommon.kt new file mode 100644 index 0000000000..a7b1c6b117 --- /dev/null +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/IncomingRoomKeyRequestCommon.kt @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2020 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.matrix.android.internal.crypto + +interface IncomingRoomKeyRequestCommon { + /** + * The user id + */ + val userId: String? + + /** + * The device id + */ + val deviceId: String? + + /** + * The request id + */ + val requestId: String? +} diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/IncomingRoomKeyRequestManager.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/IncomingRoomKeyRequestManager.kt index 814d9d5a7c..9a6458cf37 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/IncomingRoomKeyRequestManager.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/IncomingRoomKeyRequestManager.kt @@ -53,8 +53,8 @@ internal class IncomingRoomKeyRequestManager @Inject constructor( fun onRoomKeyRequestEvent(event: Event) { val roomKeyShare = event.getClearContent().toModel() when (roomKeyShare?.action) { - RoomKeyShare.ACTION_SHARE_REQUEST -> receivedRoomKeyRequests.add(IncomingRoomKeyRequest(event)) - RoomKeyShare.ACTION_SHARE_CANCELLATION -> receivedRoomKeyRequestCancellations.add(IncomingRoomKeyRequestCancellation(event)) + RoomKeyShare.ACTION_SHARE_REQUEST -> receivedRoomKeyRequests.add(IncomingRoomKeyRequest.fromEvent(event)) + RoomKeyShare.ACTION_SHARE_CANCELLATION -> receivedRoomKeyRequestCancellations.add(IncomingRoomKeyRequestCancellation.fromEvent(event)) else -> Timber.e("## onRoomKeyRequestEvent() : unsupported action ${roomKeyShare?.action}") } } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/MegolmSessionData.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/MegolmSessionData.kt index 821ed0a553..d6dae1a865 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/MegolmSessionData.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/MegolmSessionData.kt @@ -28,46 +28,46 @@ data class MegolmSessionData( * The algorithm used. */ @Json(name = "algorithm") - var algorithm: String? = null, + val algorithm: String? = null, /** * Unique id for the session. */ @Json(name = "session_id") - var sessionId: String? = null, + val sessionId: String? = null, /** * Sender's Curve25519 device key. */ @Json(name = "sender_key") - var senderKey: String? = null, + val senderKey: String? = null, /** * Room this session is used in. */ @Json(name = "room_id") - var roomId: String? = null, + val roomId: String? = null, /** * Base64'ed key data. */ @Json(name = "session_key") - var sessionKey: String? = null, + val sessionKey: String? = null, /** * Other keys the sender claims. */ @Json(name = "sender_claimed_keys") - var senderClaimedKeys: Map? = null, + val senderClaimedKeys: Map? = null, // This is a shortcut for sender_claimed_keys.get("ed25519") // Keep it for compatibility reason. @Json(name = "sender_claimed_ed25519_key") - var senderClaimedEd25519Key: String? = null, + val senderClaimedEd25519Key: String? = null, /** * Devices which forwarded this session to us (normally empty). */ @Json(name = "forwarding_curve25519_key_chain") - var forwardingCurve25519KeyChain: List? = null + val forwardingCurve25519KeyChain: List? = null ) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/OutgoingRoomKeyRequestManager.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/OutgoingRoomKeyRequestManager.kt index 5320b84b0e..b59c93ba83 100755 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/OutgoingRoomKeyRequestManager.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/OutgoingRoomKeyRequestManager.kt @@ -213,10 +213,11 @@ internal class OutgoingRoomKeyRequestManager @Inject constructor( Timber.v("## sendOutgoingRoomKeyRequest() : Requesting keys " + request.requestBody + " from " + request.recipients + " id " + request.requestId) - val requestMessage = RoomKeyShareRequest() - requestMessage.requestingDeviceId = cryptoStore.getDeviceId() - requestMessage.requestId = request.requestId - requestMessage.body = request.requestBody + val requestMessage = RoomKeyShareRequest( + requestingDeviceId = cryptoStore.getDeviceId(), + requestId = request.requestId, + body = request.requestBody + ) sendMessageToDevices(requestMessage, request.recipients, request.requestId, object : MatrixCallback { private fun onDone(state: OutgoingRoomKeyRequest.RequestState) { @@ -253,9 +254,10 @@ internal class OutgoingRoomKeyRequestManager @Inject constructor( + " to " + request.recipients + " cancellation id " + request.cancellationTxnId) - val roomKeyShareCancellation = RoomKeyShareCancellation() - roomKeyShareCancellation.requestingDeviceId = cryptoStore.getDeviceId() - roomKeyShareCancellation.requestId = request.cancellationTxnId + val roomKeyShareCancellation = RoomKeyShareCancellation( + requestingDeviceId = cryptoStore.getDeviceId(), + requestId = request.cancellationTxnId + ) sendMessageToDevices(roomKeyShareCancellation, request.recipients, request.cancellationTxnId, object : MatrixCallback { private fun onDone() { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/actions/MegolmSessionDataImporter.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/actions/MegolmSessionDataImporter.kt index ca6cfad0f9..e0d6d72c0d 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/actions/MegolmSessionDataImporter.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/actions/MegolmSessionDataImporter.kt @@ -66,12 +66,12 @@ internal class MegolmSessionDataImporter @Inject constructor(private val olmDevi totalNumbersOfImportedKeys++ // cancel any outstanding room key requests for this session - val roomKeyRequestBody = RoomKeyRequestBody() - - roomKeyRequestBody.algorithm = megolmSessionData.algorithm - roomKeyRequestBody.roomId = megolmSessionData.roomId - roomKeyRequestBody.senderKey = megolmSessionData.senderKey - roomKeyRequestBody.sessionId = megolmSessionData.sessionId + val roomKeyRequestBody = RoomKeyRequestBody( + algorithm = megolmSessionData.algorithm, + roomId = megolmSessionData.roomId, + senderKey = megolmSessionData.senderKey, + sessionId = megolmSessionData.sessionId + ) outgoingRoomKeyRequestManager.cancelRoomKeyRequest(roomKeyRequestBody) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/algorithms/megolm/MXMegolmDecryption.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/algorithms/megolm/MXMegolmDecryption.kt index 054b38ad06..90100fcc48 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/algorithms/megolm/MXMegolmDecryption.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/algorithms/megolm/MXMegolmDecryption.kt @@ -163,12 +163,12 @@ internal class MXMegolmDecryption(private val userId: String, recipients.add(senderMap) } - val requestBody = RoomKeyRequestBody() - - requestBody.roomId = event.roomId - requestBody.algorithm = encryptedEventContent.algorithm - requestBody.senderKey = encryptedEventContent.senderKey - requestBody.sessionId = encryptedEventContent.sessionId + val requestBody = RoomKeyRequestBody( + roomId = event.roomId, + algorithm = encryptedEventContent.algorithm, + senderKey = encryptedEventContent.senderKey, + sessionId = encryptedEventContent.sessionId + ) outgoingRoomKeyRequestManager.sendRoomKeyRequest(requestBody, recipients) } @@ -264,12 +264,12 @@ internal class MXMegolmDecryption(private val userId: String, if (added) { defaultKeysBackupService.maybeBackupKeys() - val content = RoomKeyRequestBody() - - content.algorithm = roomKeyContent.algorithm - content.roomId = roomKeyContent.roomId - content.sessionId = roomKeyContent.sessionId - content.senderKey = senderKey + val content = RoomKeyRequestBody( + algorithm = roomKeyContent.algorithm, + roomId = roomKeyContent.roomId, + sessionId = roomKeyContent.sessionId, + senderKey = senderKey + ) outgoingRoomKeyRequestManager.cancelRoomKeyRequest(content) @@ -290,8 +290,8 @@ internal class MXMegolmDecryption(private val userId: String, override fun hasKeysForKeyRequest(request: IncomingRoomKeyRequest): Boolean { val roomId = request.requestBody?.roomId ?: return false - val senderKey = request.requestBody?.senderKey ?: return false - val sessionId = request.requestBody?.sessionId ?: return false + val senderKey = request.requestBody.senderKey ?: return false + val sessionId = request.requestBody.sessionId ?: return false return olmDevice.hasInboundSessionKeys(roomId, senderKey, sessionId) } @@ -319,15 +319,14 @@ internal class MXMegolmDecryption(private val userId: String, return@mapCatching } Timber.v("## shareKeysWithDevice() : sharing keys for session" + - " ${body?.senderKey}|${body?.sessionId} with device $userId:$deviceId") + " ${body.senderKey}|${body.sessionId} with device $userId:$deviceId") val payloadJson = mutableMapOf("type" to EventType.FORWARDED_ROOM_KEY) - runCatching { olmDevice.getInboundGroupSession(body?.sessionId, body?.senderKey, body?.roomId) } + runCatching { olmDevice.getInboundGroupSession(body.sessionId, body.senderKey, body.roomId) } .fold( { // TODO - payloadJson["content"] = it.exportKeys() - ?: "" + payloadJson["content"] = it.exportKeys() ?: "" }, { // TODO diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/DefaultKeysBackupService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/DefaultKeysBackupService.kt index aa291e8206..5206aeedc2 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/DefaultKeysBackupService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/DefaultKeysBackupService.kt @@ -167,9 +167,7 @@ internal class DefaultKeysBackupService @Inject constructor( runCatching { withContext(coroutineDispatchers.crypto) { val olmPkDecryption = OlmPkDecryption() - val megolmBackupAuthData = MegolmBackupAuthData() - - if (password != null) { + val megolmBackupAuthData = if (password != null) { // Generate a private key from the password val backgroundProgressListener = if (progressListener == null) { null @@ -188,25 +186,30 @@ internal class DefaultKeysBackupService @Inject constructor( } val generatePrivateKeyResult = generatePrivateKeyWithPassword(password, backgroundProgressListener) - megolmBackupAuthData.publicKey = olmPkDecryption.setPrivateKey(generatePrivateKeyResult.privateKey) - megolmBackupAuthData.privateKeySalt = generatePrivateKeyResult.salt - megolmBackupAuthData.privateKeyIterations = generatePrivateKeyResult.iterations + MegolmBackupAuthData( + publicKey = olmPkDecryption.setPrivateKey(generatePrivateKeyResult.privateKey), + privateKeySalt = generatePrivateKeyResult.salt, + privateKeyIterations = generatePrivateKeyResult.iterations + ) } else { val publicKey = olmPkDecryption.generateKey() - megolmBackupAuthData.publicKey = publicKey + MegolmBackupAuthData( + publicKey = publicKey + ) } val canonicalJson = JsonCanonicalizer.getCanonicalJson(Map::class.java, megolmBackupAuthData.signalableJSONDictionary()) - megolmBackupAuthData.signatures = objectSigner.signObject(canonicalJson) + val signedMegolmBackupAuthData = megolmBackupAuthData.copy( + signatures = objectSigner.signObject(canonicalJson) + ) - val megolmBackupCreationInfo = MegolmBackupCreationInfo() - megolmBackupCreationInfo.algorithm = MXCRYPTO_ALGORITHM_MEGOLM_BACKUP - megolmBackupCreationInfo.authData = megolmBackupAuthData - megolmBackupCreationInfo.recoveryKey = computeRecoveryKey(olmPkDecryption.privateKey()) - - megolmBackupCreationInfo + MegolmBackupCreationInfo( + algorithm = MXCRYPTO_ALGORITHM_MEGOLM_BACKUP, + authData = signedMegolmBackupAuthData, + recoveryKey = computeRecoveryKey(olmPkDecryption.privateKey()) + ) } }.foldToCallback(callback) } @@ -214,11 +217,12 @@ internal class DefaultKeysBackupService @Inject constructor( override fun createKeysBackupVersion(keysBackupCreationInfo: MegolmBackupCreationInfo, callback: MatrixCallback) { - val createKeysBackupVersionBody = CreateKeysBackupVersionBody() - createKeysBackupVersionBody.algorithm = keysBackupCreationInfo.algorithm @Suppress("UNCHECKED_CAST") - createKeysBackupVersionBody.authData = MoshiProvider.providesMoshi().adapter(Map::class.java) - .fromJson(keysBackupCreationInfo.authData?.toJsonString() ?: "") as JsonDict? + val createKeysBackupVersionBody = CreateKeysBackupVersionBody( + algorithm = keysBackupCreationInfo.algorithm, + authData = MoshiProvider.providesMoshi().adapter(Map::class.java) + .fromJson(keysBackupCreationInfo.authData?.toJsonString() ?: "") as JsonDict? + ) keysBackupStateManager.state = KeysBackupState.Enabling @@ -229,14 +233,14 @@ internal class DefaultKeysBackupService @Inject constructor( // Reset backup markers. cryptoStore.resetBackupMarkers() - val keyBackupVersion = KeysVersionResult() - keyBackupVersion.algorithm = createKeysBackupVersionBody.algorithm - keyBackupVersion.authData = createKeysBackupVersionBody.authData - keyBackupVersion.version = data.version - - // We can consider that the server does not have keys yet - keyBackupVersion.count = 0 - keyBackupVersion.hash = null + val keyBackupVersion = KeysVersionResult( + algorithm = createKeysBackupVersionBody.algorithm, + authData = createKeysBackupVersionBody.authData, + version = data.version, + // We can consider that the server does not have keys yet + count = 0, + hash = null + ) enableKeysBackup(keyBackupVersion) @@ -406,7 +410,7 @@ internal class DefaultKeysBackupService @Inject constructor( return keysBackupVersionTrust } - val mySigs = authData.signatures?.get(userId) + val mySigs = authData.signatures[userId] if (mySigs.isNullOrEmpty()) { Timber.v("getKeysBackupTrust: Ignoring key backup because it lacks any signatures from this user") return keysBackupVersionTrust @@ -469,8 +473,7 @@ internal class DefaultKeysBackupService @Inject constructor( cryptoCoroutineScope.launch(coroutineDispatchers.main) { val updateKeysBackupVersionBody = withContext(coroutineDispatchers.crypto) { // Get current signatures, or create an empty set - val myUserSignatures = authData.signatures?.get(userId)?.toMutableMap() - ?: HashMap() + val myUserSignatures = authData.signatures?.get(userId)?.toMutableMap() ?: HashMap() if (trust) { // Add current device signature @@ -487,24 +490,23 @@ internal class DefaultKeysBackupService @Inject constructor( } // Create an updated version of KeysVersionResult - val updateKeysBackupVersionBody = UpdateKeysBackupVersionBody(keysBackupVersion.version!!) - - updateKeysBackupVersionBody.algorithm = keysBackupVersion.algorithm - val newMegolmBackupAuthData = authData.copy() val newSignatures = newMegolmBackupAuthData.signatures!!.toMutableMap() newSignatures[userId] = myUserSignatures - newMegolmBackupAuthData.signatures = newSignatures + val newMegolmBackupAuthDataWithNewSignature = newMegolmBackupAuthData.copy( + signatures = newSignatures + ) val moshi = MoshiProvider.providesMoshi() val adapter = moshi.adapter(Map::class.java) @Suppress("UNCHECKED_CAST") - updateKeysBackupVersionBody.authData = adapter.fromJson(newMegolmBackupAuthData.toJsonString()) as Map? - - updateKeysBackupVersionBody + UpdateKeysBackupVersionBody( + algorithm = keysBackupVersion.algorithm, + authData = adapter.fromJson(newMegolmBackupAuthDataWithNewSignature.toJsonString()) as Map?, + version = keysBackupVersion.version!!) } // And send it to the homeserver @@ -513,13 +515,13 @@ internal class DefaultKeysBackupService @Inject constructor( this.callback = object : MatrixCallback { override fun onSuccess(data: Unit) { // Relaunch the state machine on this updated backup version - val newKeysBackupVersion = KeysVersionResult() - - newKeysBackupVersion.version = keysBackupVersion.version - newKeysBackupVersion.algorithm = keysBackupVersion.algorithm - newKeysBackupVersion.count = keysBackupVersion.count - newKeysBackupVersion.hash = keysBackupVersion.hash - newKeysBackupVersion.authData = updateKeysBackupVersionBody.authData + val newKeysBackupVersion = KeysVersionResult( + algorithm = keysBackupVersion.algorithm, + authData = updateKeysBackupVersionBody.authData, + version = keysBackupVersion.version, + hash = keysBackupVersion.hash, + count = keysBackupVersion.count + ) checkAndStartWithKeysBackupVersion(newKeysBackupVersion) @@ -1024,7 +1026,7 @@ internal class DefaultKeysBackupService @Inject constructor( } // Extract the recovery key from the passphrase - val data = retrievePrivateKeyWithPassword(password, authData.privateKeySalt!!, authData.privateKeyIterations!!, progressListener) + val data = retrievePrivateKeyWithPassword(password, authData.privateKeySalt, authData.privateKeyIterations, progressListener) return computeRecoveryKey(data) } @@ -1178,14 +1180,16 @@ internal class DefaultKeysBackupService @Inject constructor( // Gather data to send to the homeserver // roomId -> sessionId -> MXKeyBackupData - val keysBackupData = KeysBackupData() - keysBackupData.roomIdToRoomKeysBackupData = HashMap() + val keysBackupData = KeysBackupData( + roomIdToRoomKeysBackupData = HashMap() + ) for (olmInboundGroupSessionWrapper in olmInboundGroupSessionWrappers) { val keyBackupData = encryptGroupSession(olmInboundGroupSessionWrapper) if (keysBackupData.roomIdToRoomKeysBackupData[olmInboundGroupSessionWrapper.roomId] == null) { - val roomKeysBackupData = RoomKeysBackupData() - roomKeysBackupData.sessionIdToKeyBackupData = HashMap() + val roomKeysBackupData = RoomKeysBackupData( + sessionIdToKeyBackupData = HashMap() + ) keysBackupData.roomIdToRoomKeysBackupData[olmInboundGroupSessionWrapper.roomId!!] = roomKeysBackupData } @@ -1301,24 +1305,21 @@ internal class DefaultKeysBackupService @Inject constructor( } // Build backup data for that key - val keyBackupData = KeyBackupData() - try { - keyBackupData.firstMessageIndex = olmInboundGroupSessionWrapper.olmInboundGroupSession!!.firstKnownIndex - } catch (e: OlmException) { - Timber.e(e, "OlmException") - } + return KeyBackupData( + firstMessageIndex = try { + olmInboundGroupSessionWrapper.olmInboundGroupSession!!.firstKnownIndex + } catch (e: OlmException) { + Timber.e(e, "OlmException") + 0L + }, + forwardedCount = olmInboundGroupSessionWrapper.forwardingCurve25519KeyChain!!.size, + isVerified = device?.isVerified == true, - keyBackupData.forwardedCount = olmInboundGroupSessionWrapper.forwardingCurve25519KeyChain!!.size - keyBackupData.isVerified = device?.isVerified == true - - val data = mapOf( - "ciphertext" to encryptedSessionBackupData!!.mCipherText, - "mac" to encryptedSessionBackupData.mMac, - "ephemeral" to encryptedSessionBackupData.mEphemeralKey) - - keyBackupData.sessionData = data - - return keyBackupData + sessionData = mapOf( + "ciphertext" to encryptedSessionBackupData!!.mCipherText, + "mac" to encryptedSessionBackupData.mMac, + "ephemeral" to encryptedSessionBackupData.mEphemeralKey) + ) } @VisibleForTesting @@ -1350,8 +1351,10 @@ internal class DefaultKeysBackupService @Inject constructor( } if (sessionBackupData != null) { - sessionBackupData.sessionId = sessionId - sessionBackupData.roomId = roomId + sessionBackupData = sessionBackupData.copy( + sessionId = sessionId, + roomId = roomId + ) } } @@ -1370,11 +1373,12 @@ internal class DefaultKeysBackupService @Inject constructor( @VisibleForTesting fun createFakeKeysBackupVersion(keysBackupCreationInfo: MegolmBackupCreationInfo, callback: MatrixCallback) { - val createKeysBackupVersionBody = CreateKeysBackupVersionBody() - createKeysBackupVersionBody.algorithm = keysBackupCreationInfo.algorithm @Suppress("UNCHECKED_CAST") - createKeysBackupVersionBody.authData = MoshiProvider.providesMoshi().adapter(Map::class.java) - .fromJson(keysBackupCreationInfo.authData?.toJsonString() ?: "") as JsonDict? + val createKeysBackupVersionBody = CreateKeysBackupVersionBody( + algorithm = keysBackupCreationInfo.algorithm, + authData = MoshiProvider.providesMoshi().adapter(Map::class.java) + .fromJson(keysBackupCreationInfo.authData?.toJsonString() ?: "") as JsonDict? + ) createKeysBackupVersionTask .configureWith(createKeysBackupVersionBody) { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/model/MegolmBackupAuthData.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/model/MegolmBackupAuthData.kt index 442b1f081c..48015a98dd 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/model/MegolmBackupAuthData.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/model/MegolmBackupAuthData.kt @@ -30,26 +30,27 @@ data class MegolmBackupAuthData( * The curve25519 public key used to encrypt the backups. */ @Json(name = "public_key") - var publicKey: String = "", + val publicKey: String = "", /** * In case of a backup created from a password, the salt associated with the backup * private key. */ @Json(name = "private_key_salt") - var privateKeySalt: String? = null, + val privateKeySalt: String? = null, /** * In case of a backup created from a password, the number of key derivations. */ @Json(name = "private_key_iterations") - var privateKeyIterations: Int? = null, + val privateKeyIterations: Int? = null, /** * Signatures of the public key. * userId -> (deviceSignKeyId -> signature) */ - var signatures: Map>? = null + @Json(name = "signatures") + val signatures: Map>? = null ) { fun toJsonString(): String { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/model/MegolmBackupCreationInfo.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/model/MegolmBackupCreationInfo.kt index a08ba9ba96..b329fa44c9 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/model/MegolmBackupCreationInfo.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/model/MegolmBackupCreationInfo.kt @@ -19,20 +19,19 @@ package im.vector.matrix.android.internal.crypto.keysbackup.model /** * Data retrieved from Olm library. algorithm and authData will be send to the homeserver, and recoveryKey will be displayed to the user */ -class MegolmBackupCreationInfo { +data class MegolmBackupCreationInfo( + /** + * The algorithm used for storing backups [org.matrix.androidsdk.crypto.MXCRYPTO_ALGORITHM_MEGOLM_BACKUP]. + */ + val algorithm: String = "", - /** - * The algorithm used for storing backups [org.matrix.androidsdk.crypto.MXCRYPTO_ALGORITHM_MEGOLM_BACKUP]. - */ - var algorithm: String = "" + /** + * Authentication data. + */ + val authData: MegolmBackupAuthData? = null, - /** - * Authentication data. - */ - var authData: MegolmBackupAuthData? = null - - /** - * The Base58 recovery key. - */ - var recoveryKey: String = "" -} + /** + * The Base58 recovery key. + */ + val recoveryKey: String = "" +) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/model/rest/CreateKeysBackupVersionBody.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/model/rest/CreateKeysBackupVersionBody.kt index 5efbc6d017..3b267280e5 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/model/rest/CreateKeysBackupVersionBody.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/model/rest/CreateKeysBackupVersionBody.kt @@ -16,7 +16,21 @@ package im.vector.matrix.android.internal.crypto.keysbackup.model.rest +import com.squareup.moshi.Json import com.squareup.moshi.JsonClass +import im.vector.matrix.android.api.util.JsonDict @JsonClass(generateAdapter = true) -class CreateKeysBackupVersionBody : KeysAlgorithmAndData() +data class CreateKeysBackupVersionBody( + /** + * The algorithm used for storing backups. Currently, only "m.megolm_backup.v1.curve25519-aes-sha2" is defined + */ + @Json(name = "algorithm") + override val algorithm: String? = null, + + /** + * algorithm-dependent data, for "m.megolm_backup.v1.curve25519-aes-sha2" see [im.vector.matrix.android.internal.crypto.keysbackup.MegolmBackupAuthData] + */ + @Json(name = "auth_data") + override val authData: JsonDict? = null +) : KeysAlgorithmAndData diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/model/rest/KeyBackupData.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/model/rest/KeyBackupData.kt index f172d45ffd..5f6e30b3b5 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/model/rest/KeyBackupData.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/model/rest/KeyBackupData.kt @@ -29,25 +29,25 @@ data class KeyBackupData( * Required. The index of the first message in the session that the key can decrypt. */ @Json(name = "first_message_index") - var firstMessageIndex: Long = 0, + val firstMessageIndex: Long = 0, /** * Required. The number of times this key has been forwarded. */ @Json(name = "forwarded_count") - var forwardedCount: Int = 0, + val forwardedCount: Int = 0, /** * Whether the device backing up the key has verified the device that the key is from. */ @Json(name = "is_verified") - var isVerified: Boolean = false, + val isVerified: Boolean = false, /** * Algorithm-dependent data. */ @Json(name = "session_data") - var sessionData: Map? = null + val sessionData: Map? = null ) { fun toJsonString(): String { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/model/rest/KeysAlgorithmAndData.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/model/rest/KeysAlgorithmAndData.kt index 6fba833589..81ca6586a3 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/model/rest/KeysAlgorithmAndData.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/model/rest/KeysAlgorithmAndData.kt @@ -16,7 +16,6 @@ package im.vector.matrix.android.internal.crypto.keysbackup.model.rest -import com.squareup.moshi.Json import im.vector.matrix.android.api.util.JsonDict import im.vector.matrix.android.internal.crypto.keysbackup.model.MegolmBackupAuthData import im.vector.matrix.android.internal.di.MoshiProvider @@ -38,19 +37,17 @@ import im.vector.matrix.android.internal.di.MoshiProvider * } * */ -open class KeysAlgorithmAndData { +interface KeysAlgorithmAndData { /** * The algorithm used for storing backups. Currently, only "m.megolm_backup.v1.curve25519-aes-sha2" is defined */ - @Json(name = "algorithm") - var algorithm: String? = null + val algorithm: String? /** * algorithm-dependent data, for "m.megolm_backup.v1.curve25519-aes-sha2" see [im.vector.matrix.android.internal.crypto.keysbackup.MegolmBackupAuthData] */ - @Json(name = "auth_data") - var authData: JsonDict? = null + val authData: JsonDict? /** * Facility method to convert authData to a MegolmBackupAuthData object diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/model/rest/KeysBackupData.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/model/rest/KeysBackupData.kt index 2f4165d8ab..240c79fd1e 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/model/rest/KeysBackupData.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/model/rest/KeysBackupData.kt @@ -24,9 +24,7 @@ import com.squareup.moshi.JsonClass */ @JsonClass(generateAdapter = true) data class KeysBackupData( - // the keys are the room IDs, and the values are RoomKeysBackupData @Json(name = "rooms") - var roomIdToRoomKeysBackupData: MutableMap = HashMap() - + val roomIdToRoomKeysBackupData: MutableMap = HashMap() ) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/model/rest/KeysVersionResult.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/model/rest/KeysVersionResult.kt index 4510cdd773..0addd1491e 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/model/rest/KeysVersionResult.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/model/rest/KeysVersionResult.kt @@ -16,16 +16,33 @@ package im.vector.matrix.android.internal.crypto.keysbackup.model.rest +import com.squareup.moshi.Json import com.squareup.moshi.JsonClass +import im.vector.matrix.android.api.util.JsonDict @JsonClass(generateAdapter = true) data class KeysVersionResult( + /** + * The algorithm used for storing backups. Currently, only "m.megolm_backup.v1.curve25519-aes-sha2" is defined + */ + @Json(name = "algorithm") + override val algorithm: String? = null, + + /** + * algorithm-dependent data, for "m.megolm_backup.v1.curve25519-aes-sha2" see [im.vector.matrix.android.internal.crypto.keysbackup.MegolmBackupAuthData] + */ + @Json(name = "auth_data") + override val authData: JsonDict? = null, + // the backup version - var version: String? = null, + @Json(name = "version") + val version: String? = null, // The hash value which is an opaque string representing stored keys in the backup - var hash: String? = null, + @Json(name = "hash") + val hash: String? = null, // The number of keys stored in the backup. - var count: Int? = null -) : KeysAlgorithmAndData() + @Json(name = "count") + val count: Int? = null +) : KeysAlgorithmAndData diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/model/rest/RoomKeysBackupData.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/model/rest/RoomKeysBackupData.kt index 5d69f63538..f3c218baca 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/model/rest/RoomKeysBackupData.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/model/rest/RoomKeysBackupData.kt @@ -24,8 +24,7 @@ import com.squareup.moshi.JsonClass */ @JsonClass(generateAdapter = true) data class RoomKeysBackupData( - // the keys are the session IDs, and the values are KeyBackupData @Json(name = "sessions") - var sessionIdToKeyBackupData: MutableMap = HashMap() + val sessionIdToKeyBackupData: MutableMap = HashMap() ) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/model/rest/UpdateKeysBackupVersionBody.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/model/rest/UpdateKeysBackupVersionBody.kt index cb8ba5e26c..9d88af20ef 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/model/rest/UpdateKeysBackupVersionBody.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/model/rest/UpdateKeysBackupVersionBody.kt @@ -16,10 +16,25 @@ package im.vector.matrix.android.internal.crypto.keysbackup.model.rest +import com.squareup.moshi.Json import com.squareup.moshi.JsonClass +import im.vector.matrix.android.api.util.JsonDict @JsonClass(generateAdapter = true) data class UpdateKeysBackupVersionBody( + /** + * The algorithm used for storing backups. Currently, only "m.megolm_backup.v1.curve25519-aes-sha2" is defined + */ + @Json(name = "algorithm") + override val algorithm: String? = null, + + /** + * algorithm-dependent data, for "m.megolm_backup.v1.curve25519-aes-sha2" see [im.vector.matrix.android.internal.crypto.keysbackup.MegolmBackupAuthData] + */ + @Json(name = "auth_data") + override val authData: JsonDict? = null, + // the backup version, mandatory + @Json(name = "version") val version: String -) : KeysAlgorithmAndData() +) : KeysAlgorithmAndData diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/MXDeviceInfo.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/MXDeviceInfo.kt index cc9b3bff74..ae53694a0f 100755 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/MXDeviceInfo.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/MXDeviceInfo.kt @@ -26,48 +26,47 @@ import java.io.Serializable @JsonClass(generateAdapter = true) data class MXDeviceInfo( - /** * The id of this device. */ @Json(name = "device_id") - var deviceId: String, + val deviceId: String, /** * the user id */ @Json(name = "user_id") - var userId: String, + val userId: String, /** * The list of algorithms supported by this device. */ @Json(name = "algorithms") - var algorithms: List? = null, + val algorithms: List? = null, /** * A map from ":" to "". */ @Json(name = "keys") - var keys: Map? = null, + val keys: Map? = null, /** * The signature of this MXDeviceInfo. * A map from "" to a map from ":" to "" */ @Json(name = "signatures") - var signatures: Map>? = null, + val signatures: Map>? = null, /* * Additional data from the home server. */ @Json(name = "unsigned") - var unsigned: JsonDict? = null, + val unsigned: JsonDict? = null, /** * Verification state of this device. */ - var verified: Int = DEVICE_VERIFICATION_UNKNOWN + val verified: Int = DEVICE_VERIFICATION_UNKNOWN ) : Serializable { /** * Tells if the device is unknown @@ -137,11 +136,11 @@ data class MXDeviceInfo( map["user_id"] = userId if (null != algorithms) { - map["algorithms"] = algorithms!! + map["algorithms"] = algorithms } if (null != keys) { - map["keys"] = keys!! + map["keys"] = keys } return map diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/OlmInboundGroupSessionWrapper.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/OlmInboundGroupSessionWrapper.kt index 361b8bc205..cf1a3b237a 100755 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/OlmInboundGroupSessionWrapper.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/OlmInboundGroupSessionWrapper.kt @@ -116,16 +116,16 @@ class OlmInboundGroupSessionWrapper : Serializable { return null } - MegolmSessionData().also { - it.senderClaimedEd25519Key = keysClaimed?.get("ed25519") - it.forwardingCurve25519KeyChain = ArrayList(forwardingCurve25519KeyChain!!) - it.senderKey = senderKey - it.senderClaimedKeys = keysClaimed - it.roomId = roomId - it.sessionId = olmInboundGroupSession!!.sessionIdentifier() - it.sessionKey = olmInboundGroupSession!!.export(olmInboundGroupSession!!.firstKnownIndex) - it.algorithm = MXCRYPTO_ALGORITHM_MEGOLM - } + MegolmSessionData( + senderClaimedEd25519Key = keysClaimed?.get("ed25519"), + forwardingCurve25519KeyChain = ArrayList(forwardingCurve25519KeyChain!!), + senderKey = senderKey, + senderClaimedKeys = keysClaimed, + roomId = roomId, + sessionId = olmInboundGroupSession!!.sessionIdentifier(), + sessionKey = olmInboundGroupSession!!.export(olmInboundGroupSession!!.firstKnownIndex), + algorithm = MXCRYPTO_ALGORITHM_MEGOLM + ) } catch (e: Exception) { Timber.e(e, "## export() : senderKey $senderKey failed") null diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/event/EncryptionEventContent.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/event/EncryptionEventContent.kt index 6de50f84c2..05e97da68d 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/event/EncryptionEventContent.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/event/EncryptionEventContent.kt @@ -23,22 +23,21 @@ import com.squareup.moshi.JsonClass */ @JsonClass(generateAdapter = true) data class EncryptionEventContent( - /** * Required. The encryption algorithm to be used to encrypt messages sent in this room. Must be 'm.megolm.v1.aes-sha2'. */ @Json(name = "algorithm") - var algorithm: String, + val algorithm: String, /** * How long the session should be used before changing it. 604800000 (a week) is the recommended default. */ @Json(name = "rotation_period_ms") - var rotationPeriodMs: Long? = null, + val rotationPeriodMs: Long? = null, /** * How many messages should be sent before changing the session. 100 is the recommended default. */ @Json(name = "rotation_period_msgs") - var rotationPeriodMsgs: Long? = null + val rotationPeriodMsgs: Long? = null ) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/event/NewDeviceContent.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/event/NewDeviceContent.kt index a6777a4f12..62fe4293e7 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/event/NewDeviceContent.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/event/NewDeviceContent.kt @@ -20,12 +20,11 @@ import com.squareup.moshi.JsonClass @JsonClass(generateAdapter = true) data class NewDeviceContent( - // the device id @Json(name = "device_id") - var deviceId: String? = null, + val deviceId: String? = null, // the room ids list @Json(name = "rooms") - var rooms: List? = null + val rooms: List? = null ) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/event/OlmEventContent.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/event/OlmEventContent.kt index 7ac0b075be..2b2b49120a 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/event/OlmEventContent.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/event/OlmEventContent.kt @@ -27,11 +27,11 @@ data class OlmEventContent( * */ @Json(name = "ciphertext") - var ciphertext: Map? = null, + val ciphertext: Map? = null, /** * the sender key */ @Json(name = "sender_key") - var senderKey: String? = null + val senderKey: String? = null ) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/DeviceInfo.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/DeviceInfo.kt index 1289ef3d92..b058fac082 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/DeviceInfo.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/DeviceInfo.kt @@ -30,31 +30,31 @@ data class DeviceInfo( * The owner user id (not documented and useless but the homeserver sent it. You should not need it) */ @Json(name = "user_id") - var user_id: String? = null, + val user_id: String? = null, /** * The device id */ @Json(name = "device_id") - var deviceId: String? = null, + val deviceId: String? = null, /** * The device display name */ @Json(name = "display_name") - var displayName: String? = null, + val displayName: String? = null, /** * The last time this device has been seen. */ @Json(name = "last_seen_ts") - var lastSeenTs: Long? = null, + val lastSeenTs: Long? = null, /** * The last ip address */ @Json(name = "last_seen_ip") - var lastSeenIp: String? = null + val lastSeenIp: String? = null ) : DatedObject { override val date: Long diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/DevicesListResponse.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/DevicesListResponse.kt index 9b50b486dc..2bf3d06299 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/DevicesListResponse.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/DevicesListResponse.kt @@ -24,5 +24,5 @@ import com.squareup.moshi.JsonClass @JsonClass(generateAdapter = true) data class DevicesListResponse( @Json(name = "devices") - var devices: List? = null + val devices: List? = null ) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/EncryptedFileInfo.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/EncryptedFileInfo.kt index 5e09b20c91..93e8b4d211 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/EncryptedFileInfo.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/EncryptedFileInfo.kt @@ -27,38 +27,38 @@ data class EncryptedFileInfo( * Required. The URL to the file. */ @Json(name = "url") - var url: String? = null, + val url: String? = null, /** * Not documented */ @Json(name = "mimetype") - var mimetype: String? = null, + val mimetype: String? = null, /** * Required. A JSON Web Key object. */ @Json(name = "key") - var key: EncryptedFileKey? = null, + val key: EncryptedFileKey? = null, /** * Required. The Initialisation Vector used by AES-CTR, encoded as unpadded base64. */ @Json(name = "iv") - var iv: String? = null, + val iv: String? = null, /** * Required. A map from an algorithm name to a hash of the ciphertext, encoded as unpadded base64. * Clients should support the SHA-256 hash, which uses the key "sha256". */ @Json(name = "hashes") - var hashes: Map? = null, + val hashes: Map? = null, /** * Required. Version of the encrypted attachments protocol. Must be "v2". */ @Json(name = "v") - var v: String? = null + val v: String? = null ) { /** * Check what the spec tells us diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/EncryptedFileKey.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/EncryptedFileKey.kt index 799819ceee..fa5885de49 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/EncryptedFileKey.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/EncryptedFileKey.kt @@ -24,31 +24,31 @@ data class EncryptedFileKey( * Required. Algorithm. Must be "A256CTR". */ @Json(name = "alg") - var alg: String? = null, + val alg: String? = null, /** * Required. Extractable. Must be true. This is a W3C extension. */ @Json(name = "ext") - var ext: Boolean? = null, + val ext: Boolean? = null, /** * Required. Key operations. Must at least contain "encrypt" and "decrypt". */ @Json(name = "key_ops") - var key_ops: List? = null, + val key_ops: List? = null, /** * Required. Key type. Must be "oct". */ @Json(name = "kty") - var kty: String? = null, + val kty: String? = null, /** * Required. The key, encoded as urlsafe unpadded base64. */ @Json(name = "k") - var k: String? = null + val k: String? = null ) { /** * Check what the spec tells us @@ -62,7 +62,7 @@ data class EncryptedFileKey( return false } - if (key_ops?.contains("encrypt") != true || key_ops?.contains("decrypt") != true) { + if (key_ops?.contains("encrypt") != true || !key_ops.contains("decrypt")) { return false } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/EncryptedMessage.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/EncryptedMessage.kt index c546cd04c4..e3ada0c0ab 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/EncryptedMessage.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/EncryptedMessage.kt @@ -21,11 +21,12 @@ import com.squareup.moshi.JsonClass @JsonClass(generateAdapter = true) data class EncryptedMessage( - var algorithm: String? = null, + @Json(name = "algorithm") + val algorithm: String? = null, @Json(name = "sender_key") - var senderKey: String? = null, + val senderKey: String? = null, @Json(name = "ciphertext") - var cipherText: Map? = null + val cipherText: Map? = null ) : SendToDeviceObject diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/KeyChangesResponse.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/KeyChangesResponse.kt index 12d27a023f..3af7d7c8c5 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/KeyChangesResponse.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/KeyChangesResponse.kt @@ -25,9 +25,9 @@ import com.squareup.moshi.JsonClass internal data class KeyChangesResponse( // list of user ids which have new devices @Json(name = "changed") - var changed: List? = null, + val changed: List? = null, // List of user ids who are no more tracked. @Json(name = "left") - var left: List? = null + val left: List? = null ) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/KeyVerificationDone.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/KeyVerificationDone.kt index c0a72d29db..bdce77b31d 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/KeyVerificationDone.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/KeyVerificationDone.kt @@ -24,7 +24,7 @@ import im.vector.matrix.android.internal.crypto.verification.VerificationInfoDon */ @JsonClass(generateAdapter = true) internal data class KeyVerificationDone( - @Json(name = "transaction_id") override var transactionID: String? = null + @Json(name = "transaction_id") override val transactionID: String? = null ) : SendToDeviceObject, VerificationInfoDone { override fun toSendToDeviceObject() = this diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/KeyVerificationRequest.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/KeyVerificationRequest.kt index 5bd09658b5..fcddb5c3d4 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/KeyVerificationRequest.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/KeyVerificationRequest.kt @@ -27,7 +27,7 @@ internal data class KeyVerificationRequest( @Json(name = "from_device") override val fromDevice: String?, @Json(name = "methods") override val methods: List, @Json(name = "timestamp") override val timestamp: Long?, - @Json(name = "transaction_id") override var transactionID: String? = null + @Json(name = "transaction_id") override val transactionID: String? = null ) : SendToDeviceObject, VerificationInfoRequest { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/KeysClaimBody.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/KeysClaimBody.kt index 38f6615dad..26ee1ebe38 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/KeysClaimBody.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/KeysClaimBody.kt @@ -24,16 +24,15 @@ import com.squareup.moshi.JsonClass */ @JsonClass(generateAdapter = true) internal data class KeysClaimBody( - /** * The time (in milliseconds) to wait when downloading keys from remote servers. 10 seconds is the recommended default. */ @Json(name = "timeout") - var timeout: Int? = null, + val timeout: Int? = null, /** * Required. The keys to be claimed. A map from user ID, to a map from device ID to algorithm name. */ @Json(name = "one_time_keys") - var oneTimeKeys: Map> + val oneTimeKeys: Map> ) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/KeysClaimResponse.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/KeysClaimResponse.kt index 59567ba77a..3483873fbb 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/KeysClaimResponse.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/KeysClaimResponse.kt @@ -24,11 +24,10 @@ import com.squareup.moshi.JsonClass */ @JsonClass(generateAdapter = true) internal data class KeysClaimResponse( - /** * The requested keys ordered by device by user. * TODO Type does not match spec, should be Map */ @Json(name = "one_time_keys") - var oneTimeKeys: Map>>>? = null + val oneTimeKeys: Map>>>? = null ) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/KeysQueryBody.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/KeysQueryBody.kt index 3dca696fcd..da2dd781dd 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/KeysQueryBody.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/KeysQueryBody.kt @@ -25,12 +25,11 @@ import com.squareup.moshi.JsonClass */ @JsonClass(generateAdapter = true) internal data class KeysQueryBody( - /** * The time (in milliseconds) to wait when downloading keys from remote servers. 10 seconds is the recommended default. */ @Json(name = "timeout") - var timeout: Int? = null, + val timeout: Int? = null, /** * Required. The keys to be downloaded. @@ -45,6 +44,5 @@ internal data class KeysQueryBody( * by the notification in that sync. */ @Json(name = "token") - var token: String? = null - + val token: String? = null ) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/KeysUploadResponse.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/KeysUploadResponse.kt index 38360fa1cd..cd71749acf 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/KeysUploadResponse.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/KeysUploadResponse.kt @@ -23,13 +23,11 @@ import com.squareup.moshi.JsonClass */ @JsonClass(generateAdapter = true) internal data class KeysUploadResponse( - /** * The count per algorithm as returned by the home server: a map (algorithm to count). */ @Json(name = "one_time_key_counts") - var oneTimeKeyCounts: Map? = null - + val oneTimeKeyCounts: Map? = null ) { /** * Helper methods to extract information from 'oneTimeKeyCounts' diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/RoomKeyRequestBody.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/RoomKeyRequestBody.kt index 06f70ee25b..3eb6600e5e 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/RoomKeyRequestBody.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/RoomKeyRequestBody.kt @@ -25,14 +25,14 @@ import com.squareup.moshi.JsonClass @JsonClass(generateAdapter = true) data class RoomKeyRequestBody( @Json(name = "algorithm") - var algorithm: String? = null, + val algorithm: String? = null, @Json(name = "room_id") - var roomId: String? = null, + val roomId: String? = null, @Json(name = "sender_key") - var senderKey: String? = null, + val senderKey: String? = null, @Json(name = "session_id") - var sessionId: String? = null + val sessionId: String? = null ) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/RoomKeyShare.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/RoomKeyShare.kt index de2345e002..4ea95d84ae 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/RoomKeyShare.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/RoomKeyShare.kt @@ -15,21 +15,17 @@ */ package im.vector.matrix.android.internal.crypto.model.rest -import com.squareup.moshi.Json - /** - * Parent class representing an room key action request + * Interface representing an room key action request * Note: this class cannot be abstract because of [org.matrix.androidsdk.core.JsonUtils.toRoomKeyShare] */ -internal open class RoomKeyShare : SendToDeviceObject { +internal interface RoomKeyShare : SendToDeviceObject { - var action: String? = null + val action: String? - @Json(name = "requesting_device_id") - var requestingDeviceId: String? = null + val requestingDeviceId: String? - @Json(name = "request_id") - var requestId: String? = null + val requestId: String? companion object { const val ACTION_SHARE_REQUEST = "request" diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/RoomKeyShareCancellation.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/RoomKeyShareCancellation.kt index fcfbfccbac..110eed04c1 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/RoomKeyShareCancellation.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/RoomKeyShareCancellation.kt @@ -15,14 +15,21 @@ */ package im.vector.matrix.android.internal.crypto.model.rest +import com.squareup.moshi.Json import com.squareup.moshi.JsonClass +import im.vector.matrix.android.internal.crypto.model.rest.RoomKeyShare.Companion.ACTION_SHARE_CANCELLATION /** - * Class representing an room key request cancellation content + * Class representing a room key request cancellation content */ @JsonClass(generateAdapter = true) -internal class RoomKeyShareCancellation : RoomKeyShare() { - init { - action = ACTION_SHARE_CANCELLATION - } -} +internal data class RoomKeyShareCancellation( + @Json(name = "action") + override val action: String? = ACTION_SHARE_CANCELLATION, + + @Json(name = "requesting_device_id") + override val requestingDeviceId: String? = null, + + @Json(name = "request_id") + override val requestId: String? = null +) : RoomKeyShare diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/RoomKeyShareRequest.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/RoomKeyShareRequest.kt index 3b9d210812..d92bc03aab 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/RoomKeyShareRequest.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/RoomKeyShareRequest.kt @@ -16,16 +16,23 @@ */ package im.vector.matrix.android.internal.crypto.model.rest +import com.squareup.moshi.Json import com.squareup.moshi.JsonClass /** - * Class representing an room key request content + * Class representing a room key request content */ @JsonClass(generateAdapter = true) -internal class RoomKeyShareRequest : RoomKeyShare() { - var body: RoomKeyRequestBody? = null +internal data class RoomKeyShareRequest( + @Json(name = "action") + override val action: String? = RoomKeyShare.ACTION_SHARE_REQUEST, - init { - action = ACTION_SHARE_REQUEST - } -} + @Json(name = "requesting_device_id") + override val requestingDeviceId: String? = null, + + @Json(name = "request_id") + override val requestId: String? = null, + + @Json(name = "body") + val body: RoomKeyRequestBody? = null +) : RoomKeyShare diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/UpdateDeviceInfoBody.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/UpdateDeviceInfoBody.kt index f2ea24a960..8ae373ba8c 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/UpdateDeviceInfoBody.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/UpdateDeviceInfoBody.kt @@ -25,5 +25,5 @@ internal data class UpdateDeviceInfoBody( * The new display name for this device. If not given, the display name is unchanged. */ @Json(name = "display_name") - var displayName: String? = null + val displayName: String? = null ) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/store/IMXCryptoStore.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/store/IMXCryptoStore.kt index 3a12df2cd7..7262eb5bb1 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/store/IMXCryptoStore.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/store/IMXCryptoStore.kt @@ -20,6 +20,7 @@ package im.vector.matrix.android.internal.crypto.store import androidx.lifecycle.LiveData import im.vector.matrix.android.api.session.crypto.crosssigning.MXCrossSigningInfo import im.vector.matrix.android.api.util.Optional +import im.vector.matrix.android.internal.crypto.IncomingRoomKeyRequestCommon import im.vector.matrix.android.internal.crypto.IncomingRoomKeyRequest import im.vector.matrix.android.internal.crypto.NewSessionListener import im.vector.matrix.android.internal.crypto.OutgoingRoomKeyRequest @@ -382,7 +383,7 @@ internal interface IMXCryptoStore { * * @param incomingRoomKeyRequest the incoming key request */ - fun deleteIncomingRoomKeyRequest(incomingRoomKeyRequest: IncomingRoomKeyRequest) + fun deleteIncomingRoomKeyRequest(incomingRoomKeyRequest: IncomingRoomKeyRequestCommon) /** * Search an IncomingRoomKeyRequest diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/store/db/RealmCryptoStore.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/store/db/RealmCryptoStore.kt index 00a496cae4..8552868252 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/store/db/RealmCryptoStore.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/store/db/RealmCryptoStore.kt @@ -23,6 +23,7 @@ import im.vector.matrix.android.api.auth.data.Credentials import im.vector.matrix.android.api.session.crypto.crosssigning.MXCrossSigningInfo import im.vector.matrix.android.api.util.Optional import im.vector.matrix.android.api.util.toOptional +import im.vector.matrix.android.internal.crypto.IncomingRoomKeyRequestCommon import im.vector.matrix.android.internal.crypto.IncomingRoomKeyRequest import im.vector.matrix.android.internal.crypto.NewSessionListener import im.vector.matrix.android.internal.crypto.OutgoingRoomKeyRequest @@ -888,7 +889,7 @@ internal class RealmCryptoStore @Inject constructor( } } - override fun deleteIncomingRoomKeyRequest(incomingRoomKeyRequest: IncomingRoomKeyRequest) { + override fun deleteIncomingRoomKeyRequest(incomingRoomKeyRequest: IncomingRoomKeyRequestCommon) { doRealmTransaction(realmConfiguration) { it.where() .equalTo(IncomingRoomKeyRequestEntityFields.USER_ID, incomingRoomKeyRequest.userId) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/store/db/model/IncomingRoomKeyRequestEntity.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/store/db/model/IncomingRoomKeyRequestEntity.kt index 9b1d116aa9..38cece99ac 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/store/db/model/IncomingRoomKeyRequestEntity.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/store/db/model/IncomingRoomKeyRequestEntity.kt @@ -32,17 +32,17 @@ internal open class IncomingRoomKeyRequestEntity( ) : RealmObject() { fun toIncomingRoomKeyRequest(): IncomingRoomKeyRequest { - return IncomingRoomKeyRequest().also { - it.requestId = requestId - it.userId = userId - it.deviceId = deviceId - it.requestBody = RoomKeyRequestBody().apply { - algorithm = requestBodyAlgorithm - roomId = requestBodyRoomId - senderKey = requestBodySenderKey - sessionId = requestBodySessionId - } - } + return IncomingRoomKeyRequest( + requestId = requestId, + userId = userId, + deviceId = deviceId, + requestBody = RoomKeyRequestBody( + algorithm = requestBodyAlgorithm, + roomId = requestBodyRoomId, + senderKey = requestBodySenderKey, + sessionId = requestBodySessionId + ) + ) } fun putRequestBody(requestBody: RoomKeyRequestBody?) { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/store/db/model/OutgoingRoomKeyRequestEntity.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/store/db/model/OutgoingRoomKeyRequestEntity.kt index 3130bd2f89..86fc177f2b 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/store/db/model/OutgoingRoomKeyRequestEntity.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/store/db/model/OutgoingRoomKeyRequestEntity.kt @@ -43,12 +43,12 @@ internal open class OutgoingRoomKeyRequestEntity( fun toOutgoingRoomKeyRequest(): OutgoingRoomKeyRequest { val cancellationTxnId = this.cancellationTxnId return OutgoingRoomKeyRequest( - RoomKeyRequestBody().apply { - algorithm = requestBodyAlgorithm - roomId = requestBodyRoomId - senderKey = requestBodySenderKey - sessionId = requestBodySessionId - }, + RoomKeyRequestBody( + algorithm = requestBodyAlgorithm, + roomId = requestBodyRoomId, + senderKey = requestBodySenderKey, + sessionId = requestBodySessionId + ), getRecipients()!!, requestId!!, OutgoingRoomKeyRequest.RequestState.from(state) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/tasks/DownloadKeysForUsersTask.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/tasks/DownloadKeysForUsersTask.kt index 2e11bb1b3e..94fe3c1e8d 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/tasks/DownloadKeysForUsersTask.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/tasks/DownloadKeysForUsersTask.kt @@ -29,7 +29,8 @@ internal interface DownloadKeysForUsersTask : Task?, // the up-to token - val token: String?) + val token: String? + ) } internal class DefaultDownloadKeysForUsers @Inject constructor( @@ -41,13 +42,10 @@ internal class DefaultDownloadKeysForUsers @Inject constructor( val downloadQuery = params.userIds?.associateWith { emptyMap() }.orEmpty() val body = KeysQueryBody( - deviceKeys = downloadQuery + deviceKeys = downloadQuery, + token = params.token?.takeIf { it.isNotEmpty() } ) - if (!params.token.isNullOrEmpty()) { - body.token = params.token - } - return executeRequest(eventBus) { apiCall = cryptoApi.downloadKeysForUsers(body) } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/filter/Filter.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/filter/Filter.kt index 9acdacd897..fc0472e32f 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/filter/Filter.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/filter/Filter.kt @@ -24,13 +24,13 @@ import com.squareup.moshi.JsonClass */ @JsonClass(generateAdapter = true) data class Filter( - @Json(name = "limit") var limit: Int? = null, - @Json(name = "senders") var senders: MutableList? = null, - @Json(name = "not_senders") var notSenders: MutableList? = null, - @Json(name = "types") var types: MutableList? = null, - @Json(name = "not_types") var notTypes: MutableList? = null, - @Json(name = "rooms") var rooms: MutableList? = null, - @Json(name = "not_rooms") var notRooms: MutableList? = null + @Json(name = "limit") val limit: Int? = null, + @Json(name = "senders") val senders: List? = null, + @Json(name = "not_senders") val notSenders: List? = null, + @Json(name = "types") val types: List? = null, + @Json(name = "not_types") val notTypes: List? = null, + @Json(name = "rooms") val rooms: List? = null, + @Json(name = "not_rooms") val notRooms: List? = null ) { fun hasData(): Boolean { return (limit != null diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/filter/FilterBody.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/filter/FilterBody.kt index fa66470c9b..535c66f637 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/filter/FilterBody.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/filter/FilterBody.kt @@ -26,11 +26,11 @@ import im.vector.matrix.android.internal.di.MoshiProvider */ @JsonClass(generateAdapter = true) internal data class FilterBody( - @Json(name = "event_fields") var eventFields: List? = null, - @Json(name = "event_format") var eventFormat: String? = null, - @Json(name = "presence") var presence: Filter? = null, - @Json(name = "account_data") var accountData: Filter? = null, - @Json(name = "room") var room: RoomFilter? = null + @Json(name = "event_fields") val eventFields: List? = null, + @Json(name = "event_format") val eventFormat: String? = null, + @Json(name = "presence") val presence: Filter? = null, + @Json(name = "account_data") val accountData: Filter? = null, + @Json(name = "room") val room: RoomFilter? = null ) { fun toJSONString(): String { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/filter/FilterFactory.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/filter/FilterFactory.kt index 86c94d3dfa..a070759de9 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/filter/FilterFactory.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/filter/FilterFactory.kt @@ -21,32 +21,30 @@ import im.vector.matrix.android.api.session.events.model.EventType internal object FilterFactory { fun createDefaultFilterBody(): FilterBody { - val filterBody = FilterBody() - FilterUtil.enableLazyLoading(filterBody, true) - return filterBody + return FilterUtil.enableLazyLoading(FilterBody(), true) } fun createRiotFilterBody(): FilterBody { - val filterBody = FilterBody() - filterBody.room = RoomFilter().apply { - timeline = createRiotTimelineFilter() - state = createRiotStateFilter() - } - return filterBody + return FilterBody( + room = RoomFilter( + timeline = createRiotTimelineFilter(), + state = createRiotStateFilter() + ) + ) } fun createDefaultRoomFilter(): RoomEventFilter { - return RoomEventFilter().apply { - lazyLoadMembers = true - } + return RoomEventFilter( + lazyLoadMembers = true + ) } fun createRiotRoomFilter(): RoomEventFilter { - return RoomEventFilter().apply { - lazyLoadMembers = true - // TODO Enable this for optimization - // types = (listOfSupportedEventTypes + listOfSupportedStateEventTypes).toMutableList() - } + return RoomEventFilter( + lazyLoadMembers = true + // TODO Enable this for optimization + // types = (listOfSupportedEventTypes + listOfSupportedStateEventTypes).toMutableList() + ) } private fun createRiotTimelineFilter(): RoomEventFilter { @@ -57,9 +55,9 @@ internal object FilterFactory { } private fun createRiotStateFilter(): RoomEventFilter { - return RoomEventFilter().apply { - lazyLoadMembers = true - } + return RoomEventFilter( + lazyLoadMembers = true + ) } // Get only managed types by Riot diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/filter/FilterResponse.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/filter/FilterResponse.kt index b27ddae9d3..75e2c23da9 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/filter/FilterResponse.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/filter/FilterResponse.kt @@ -24,5 +24,5 @@ import com.squareup.moshi.JsonClass */ @JsonClass(generateAdapter = true) data class FilterResponse( - @Json(name = "filter_id") var filterId: String + @Json(name = "filter_id") val filterId: String ) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/filter/FilterUtil.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/filter/FilterUtil.kt index d3020b3fa6..000df0d80e 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/filter/FilterUtil.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/filter/FilterUtil.kt @@ -21,7 +21,6 @@ internal object FilterUtil { /** * Patch the filterBody to enable or disable the data save mode * - * * If data save mode is on, FilterBody will contains * FIXME New expected filter: * "{\"room\": {\"ephemeral\": {\"notTypes\": [\"m.typing\"]}}, \"presence\":{\"notTypes\": [\"*\"]}}" @@ -29,6 +28,7 @@ internal object FilterUtil { * @param filterBody filterBody to patch * @param useDataSaveMode true to enable data save mode */ + /* fun enableDataSaveMode(filterBody: FilterBody, useDataSaveMode: Boolean) { if (useDataSaveMode) { // Enable data save mode @@ -79,9 +79,10 @@ internal object FilterUtil { } } } + */ /** - * Patch the filterBody to enable or disable the lazy loading + * Compute a new filterBody to enable or disable the lazy loading * * * If lazy loading is on, the filterBody will looks like @@ -90,29 +91,23 @@ internal object FilterUtil { * @param filterBody filterBody to patch * @param useLazyLoading true to enable lazy loading */ - fun enableLazyLoading(filterBody: FilterBody, useLazyLoading: Boolean) { + fun enableLazyLoading(filterBody: FilterBody, useLazyLoading: Boolean): FilterBody { if (useLazyLoading) { // Enable lazy loading - if (filterBody.room == null) { - filterBody.room = RoomFilter() - } - if (filterBody.room!!.state == null) { - filterBody.room!!.state = RoomEventFilter() - } - - filterBody.room!!.state!!.lazyLoadMembers = true + return filterBody.copy( + room = filterBody.room?.copy( + state = filterBody.room.state?.copy(lazyLoadMembers = true) + ?: RoomEventFilter(lazyLoadMembers = true) + ) + ?: RoomFilter(state = RoomEventFilter(lazyLoadMembers = true)) + ) } else { - if (filterBody.room != null && filterBody.room!!.state != null) { - filterBody.room!!.state!!.lazyLoadMembers = null + val newRoomEventFilter = filterBody.room?.state?.copy(lazyLoadMembers = null)?.takeIf { it.hasData() } + val newRoomFilter = filterBody.room?.copy(state = newRoomEventFilter)?.takeIf { it.hasData() } - if (!filterBody.room!!.state!!.hasData()) { - filterBody.room!!.state = null - } - - if (!filterBody.room!!.hasData()) { - filterBody.room = null - } - } + return filterBody.copy( + room = newRoomFilter + ) } } } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/filter/RoomEventFilter.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/filter/RoomEventFilter.kt index ee81e399ee..9cdccc5c8b 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/filter/RoomEventFilter.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/filter/RoomEventFilter.kt @@ -26,14 +26,14 @@ import im.vector.matrix.android.internal.di.MoshiProvider @JsonClass(generateAdapter = true) data class RoomEventFilter( @Json(name = "limit") var limit: Int? = null, - @Json(name = "not_senders") var notSenders: MutableList? = null, - @Json(name = "not_types") var notTypes: MutableList? = null, - @Json(name = "senders") var senders: MutableList? = null, - @Json(name = "types") var types: MutableList? = null, - @Json(name = "rooms") var rooms: MutableList? = null, - @Json(name = "not_rooms") var notRooms: List? = null, - @Json(name = "contains_url") var containsUrl: Boolean? = null, - @Json(name = "lazy_load_members") var lazyLoadMembers: Boolean? = null + @Json(name = "not_senders") val notSenders: List? = null, + @Json(name = "not_types") val notTypes: List? = null, + @Json(name = "senders") val senders: List? = null, + @Json(name = "types") val types: List? = null, + @Json(name = "rooms") val rooms: List? = null, + @Json(name = "not_rooms") val notRooms: List? = null, + @Json(name = "contains_url") val containsUrl: Boolean? = null, + @Json(name = "lazy_load_members") val lazyLoadMembers: Boolean? = null ) { fun toJSONString(): String { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/filter/RoomFilter.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/filter/RoomFilter.kt index 4742bdb988..3109763570 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/filter/RoomFilter.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/filter/RoomFilter.kt @@ -24,13 +24,13 @@ import com.squareup.moshi.JsonClass */ @JsonClass(generateAdapter = true) data class RoomFilter( - @Json(name = "not_rooms") var notRooms: List? = null, - @Json(name = "rooms") var rooms: List? = null, - @Json(name = "ephemeral") var ephemeral: RoomEventFilter? = null, - @Json(name = "include_leave") var includeLeave: Boolean? = null, - @Json(name = "state") var state: RoomEventFilter? = null, - @Json(name = "timeline") var timeline: RoomEventFilter? = null, - @Json(name = "account_data") var accountData: RoomEventFilter? = null + @Json(name = "not_rooms") val notRooms: List? = null, + @Json(name = "rooms") val rooms: List? = null, + @Json(name = "ephemeral") val ephemeral: RoomEventFilter? = null, + @Json(name = "include_leave") val includeLeave: Boolean? = null, + @Json(name = "state") val state: RoomEventFilter? = null, + @Json(name = "timeline") val timeline: RoomEventFilter? = null, + @Json(name = "account_data") val accountData: RoomEventFilter? = null ) { fun hasData(): Boolean { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/model/GroupSyncProfile.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/model/GroupSyncProfile.kt index 6d31e84d61..00e3377aa9 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/model/GroupSyncProfile.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/model/GroupSyncProfile.kt @@ -24,10 +24,10 @@ internal data class GroupSyncProfile( /** * The name of the group, if any. May be nil. */ - @Json(name = "name") var name: String? = null, + @Json(name = "name") val name: String? = null, /** * The URL for the group's avatar. May be nil. */ - @Json(name = "avatar_url") var avatarUrl: String? = null + @Json(name = "avatar_url") val avatarUrl: String? = null )