From 114101699d1c0373b0c5a3ea01ddf7fd7f1d9d5c Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 4 Nov 2019 18:50:23 +0100 Subject: [PATCH] Fix potential ignoring of account data (return@foreach) --- .../internal/session/sync/UserAccountDataSyncHandler.kt | 8 +++----- .../session/sync/model/UserAccountDataFallback.kt | 1 + 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/UserAccountDataSyncHandler.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/UserAccountDataSyncHandler.kt index 56b96b428d..10e9001cc2 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/UserAccountDataSyncHandler.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/UserAccountDataSyncHandler.kt @@ -26,10 +26,7 @@ import im.vector.matrix.android.internal.database.query.where import im.vector.matrix.android.internal.di.UserId import im.vector.matrix.android.internal.session.pushers.SavePushRulesTask import im.vector.matrix.android.internal.session.room.membership.RoomMembers -import im.vector.matrix.android.internal.session.sync.model.InvitedRoomSync -import im.vector.matrix.android.internal.session.sync.model.UserAccountDataDirectMessages -import im.vector.matrix.android.internal.session.sync.model.UserAccountDataPushRules -import im.vector.matrix.android.internal.session.sync.model.UserAccountDataSync +import im.vector.matrix.android.internal.session.sync.model.* import im.vector.matrix.android.internal.session.user.accountdata.DirectChatsHelper import im.vector.matrix.android.internal.session.user.accountdata.UpdateUserAccountDataTask import im.vector.matrix.android.internal.task.TaskExecutor @@ -51,7 +48,8 @@ internal class UserAccountDataSyncHandler @Inject constructor(private val monarc when (it) { is UserAccountDataDirectMessages -> handleDirectChatRooms(it) is UserAccountDataPushRules -> handlePushRules(it) - else -> return@forEach + is UserAccountDataFallback -> Timber.d("Receive account data of unhandled type ${it.type}") + else -> error("Missing code here!") } } monarchy.doWithRealm { realm -> diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/model/UserAccountDataFallback.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/model/UserAccountDataFallback.kt index 70d28c084f..99196bcaa2 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/model/UserAccountDataFallback.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/model/UserAccountDataFallback.kt @@ -21,5 +21,6 @@ import com.squareup.moshi.JsonClass @JsonClass(generateAdapter = true) internal data class UserAccountDataFallback( + @Json(name = "type") val type: String, @Json(name = "content") val content: Map ) : UserAccountData