mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-27 03:49:04 +03:00
Mapping between entity/model
This commit is contained in:
parent
f283a95c03
commit
65724fbdd4
4 changed files with 54 additions and 4 deletions
|
@ -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?,
|
||||
)
|
||||
|
|
|
@ -58,8 +58,10 @@ internal object EventAnnotationsSummaryMapper {
|
|||
},
|
||||
pollResponseSummary = annotationsSummary.pollResponseSummary?.let {
|
||||
PollResponseAggregatedSummaryEntityMapper.map(it)
|
||||
},
|
||||
liveLocationAggregatedSummary = annotationsSummary.liveLocationAggregatedSummary?.let {
|
||||
LiveLocationAggregatedSummaryMapper.map(it)
|
||||
}
|
||||
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<MessageLiveLocationContent>()
|
||||
)
|
||||
}
|
||||
|
||||
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())
|
||||
)
|
||||
}
|
||||
}
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue