diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/livelocation/LiveLocationAggregatedSummary.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/livelocation/LiveLocationAggregatedSummary.kt index ff8a71614a..e879c569ea 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/livelocation/LiveLocationAggregatedSummary.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/livelocation/LiveLocationAggregatedSummary.kt @@ -27,7 +27,7 @@ data class LiveLocationAggregatedSummary( */ val eventId: String, val roomId: String, - val isLive: Boolean, - val endOfLiveTimestampAsMilliseconds: Long, - val lastLocationContent: MessageLiveLocationContent? = null, + val isLive: Boolean?, + val endOfLiveTimestampAsMilliseconds: Long?, + val lastLocationContent: MessageLiveLocationContent?, ) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/EventAnnotationsSummaryMapper.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/EventAnnotationsSummaryMapper.kt index 4a26b4c4bf..79184cdc4b 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/EventAnnotationsSummaryMapper.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/EventAnnotationsSummaryMapper.kt @@ -58,8 +58,10 @@ internal object EventAnnotationsSummaryMapper { }, pollResponseSummary = annotationsSummary.pollResponseSummary?.let { PollResponseAggregatedSummaryEntityMapper.map(it) + }, + liveLocationAggregatedSummary = annotationsSummary.liveLocationAggregatedSummary?.let { + LiveLocationAggregatedSummaryMapper.map(it) } - ) } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/LiveLocationAggregatedSummaryMapper.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/LiveLocationAggregatedSummaryMapper.kt new file mode 100644 index 0000000000..69e01bc551 --- /dev/null +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/LiveLocationAggregatedSummaryMapper.kt @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2022 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 org.matrix.android.sdk.internal.database.mapper + +import org.matrix.android.sdk.api.session.events.model.toContent +import org.matrix.android.sdk.api.session.events.model.toModel +import org.matrix.android.sdk.api.session.room.model.livelocation.LiveLocationAggregatedSummary +import org.matrix.android.sdk.api.session.room.model.message.MessageLiveLocationContent +import org.matrix.android.sdk.internal.database.model.livelocation.LiveLocationAggregatedSummaryEntity + +internal object LiveLocationAggregatedSummaryMapper { + + // TODO add unit tests + fun map(entity: LiveLocationAggregatedSummaryEntity): LiveLocationAggregatedSummary { + return LiveLocationAggregatedSummary( + eventId = entity.eventId, + roomId = entity.roomId, + isLive = entity.isLive, + endOfLiveTimestampAsMilliseconds = entity.endOfLiveTimestampAsMilliseconds, + lastLocationContent = ContentMapper.map(entity.lastLocationContent).toModel() + ) + } + + fun map(model: LiveLocationAggregatedSummary): LiveLocationAggregatedSummaryEntity { + return LiveLocationAggregatedSummaryEntity( + eventId = model.eventId, + roomId = model.roomId, + isLive = model.isLive, + endOfLiveTimestampAsMilliseconds = model.endOfLiveTimestampAsMilliseconds, + lastLocationContent = ContentMapper.map(model.lastLocationContent.toContent()) + ) + } +} diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/aggregation/livelocation/DefaultLiveLocationAggregationProcessor.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/aggregation/livelocation/DefaultLiveLocationAggregationProcessor.kt index 603c3f9405..595b71cea0 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/aggregation/livelocation/DefaultLiveLocationAggregationProcessor.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/aggregation/livelocation/DefaultLiveLocationAggregationProcessor.kt @@ -31,6 +31,7 @@ import javax.inject.Inject internal class DefaultLiveLocationAggregationProcessor @Inject constructor() : LiveLocationAggregationProcessor { + // TODO add unit tests override fun handleBeaconInfo(realm: Realm, event: Event, content: LiveLocationBeaconContent, roomId: String, isLocalEcho: Boolean) { if (event.senderId.isNullOrEmpty() || isLocalEcho) { return