Fix / crash No JsonAdapter for GossipingToDeviceObject

This commit is contained in:
Valere 2020-02-26 18:58:44 +01:00
parent b67735c31a
commit d5137897c1
2 changed files with 12 additions and 1 deletions

View File

@ -24,6 +24,7 @@ import im.vector.matrix.android.api.session.crypto.keyshare.GossipingRequestList
import im.vector.matrix.android.api.session.events.model.Event
import im.vector.matrix.android.api.session.events.model.EventType
import im.vector.matrix.android.api.session.events.model.toModel
import im.vector.matrix.android.internal.crypto.model.rest.GossipingDefaultContent
import im.vector.matrix.android.internal.crypto.model.rest.GossipingToDeviceObject
import im.vector.matrix.android.internal.crypto.store.IMXCryptoStore
import im.vector.matrix.android.internal.session.SessionScope
@ -58,7 +59,7 @@ internal class IncomingRoomKeyRequestManager @Inject constructor(
* @param event the announcement event.
*/
fun onGossipingRequestEvent(event: Event) {
val roomKeyShare = event.getClearContent().toModel<GossipingToDeviceObject>()
val roomKeyShare = event.getClearContent().toModel<GossipingDefaultContent>()
when (roomKeyShare?.action) {
GossipingToDeviceObject.ACTION_SHARE_REQUEST -> {
if (event.getClearType() == EventType.REQUEST_SECRET) {

View File

@ -15,6 +15,9 @@
*/
package im.vector.matrix.android.internal.crypto.model.rest
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
/**
* Interface representing an room key action request
* Note: this class cannot be abstract because of [org.matrix.androidsdk.core.JsonUtils.toRoomKeyShare]
@ -32,3 +35,10 @@ internal interface GossipingToDeviceObject : SendToDeviceObject {
const val ACTION_SHARE_CANCELLATION = "request_cancellation"
}
}
@JsonClass(generateAdapter = true)
data class GossipingDefaultContent(
@Json(name = "action") override val action: String?,
@Json(name = "requesting_device_id") override val requestingDeviceId: String?,
@Json(name = "m.request_id") override val requestId: String? = null
) : GossipingToDeviceObject