mirror of
https://github.com/element-hq/element-android
synced 2024-11-27 20:06:51 +03:00
Fix getting related eventId for location events
This commit is contained in:
parent
59567e39b4
commit
7aa958b9ff
3 changed files with 21 additions and 8 deletions
|
@ -194,7 +194,14 @@ internal class EventRelationsAggregationProcessor @Inject constructor(
|
||||||
}
|
}
|
||||||
in EventType.BEACON_LOCATION_DATA -> {
|
in EventType.BEACON_LOCATION_DATA -> {
|
||||||
event.getClearContent().toModel<MessageBeaconLocationDataContent>(catchError = true)?.let {
|
event.getClearContent().toModel<MessageBeaconLocationDataContent>(catchError = true)?.let {
|
||||||
liveLocationAggregationProcessor.handleBeaconLocationData(realm, event, it, roomId, isLocalEcho)
|
liveLocationAggregationProcessor.handleBeaconLocationData(
|
||||||
|
realm,
|
||||||
|
event,
|
||||||
|
it,
|
||||||
|
roomId,
|
||||||
|
event.getRelationContent()?.eventId,
|
||||||
|
isLocalEcho
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,22 +60,27 @@ internal class DefaultLiveLocationAggregationProcessor @Inject constructor() : L
|
||||||
aggregatedSummary.isActive = content.isLive
|
aggregatedSummary.isActive = content.isLive
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun handleBeaconLocationData(realm: Realm, event: Event, content: MessageBeaconLocationDataContent, roomId: String, isLocalEcho: Boolean) {
|
override fun handleBeaconLocationData(
|
||||||
|
realm: Realm,
|
||||||
|
event: Event,
|
||||||
|
content: MessageBeaconLocationDataContent,
|
||||||
|
roomId: String,
|
||||||
|
relatedEventId: String?,
|
||||||
|
isLocalEcho: Boolean
|
||||||
|
) {
|
||||||
if (event.senderId.isNullOrEmpty() || isLocalEcho) {
|
if (event.senderId.isNullOrEmpty() || isLocalEcho) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val targetEventId = content.relatesTo?.eventId
|
if (relatedEventId.isNullOrEmpty()) {
|
||||||
|
Timber.w("no related event id found for the live location content")
|
||||||
if (targetEventId.isNullOrEmpty()) {
|
|
||||||
Timber.w("no target event id found for the live location content")
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val aggregatedSummary = LiveLocationShareAggregatedSummaryEntity.getOrCreate(
|
val aggregatedSummary = LiveLocationShareAggregatedSummaryEntity.getOrCreate(
|
||||||
realm = realm,
|
realm = realm,
|
||||||
roomId = roomId,
|
roomId = roomId,
|
||||||
eventId = targetEventId
|
eventId = relatedEventId
|
||||||
)
|
)
|
||||||
val updatedLocationTimestamp = content.getBestTimestampMillis() ?: 0
|
val updatedLocationTimestamp = content.getBestTimestampMillis() ?: 0
|
||||||
val currentLocationTimestamp = ContentMapper
|
val currentLocationTimestamp = ContentMapper
|
||||||
|
@ -85,7 +90,7 @@ internal class DefaultLiveLocationAggregationProcessor @Inject constructor() : L
|
||||||
?: 0
|
?: 0
|
||||||
|
|
||||||
if (updatedLocationTimestamp.isMoreRecentThan(currentLocationTimestamp)) {
|
if (updatedLocationTimestamp.isMoreRecentThan(currentLocationTimestamp)) {
|
||||||
Timber.d("updating last location of the summary of id=$targetEventId")
|
Timber.d("updating last location of the summary of id=$relatedEventId")
|
||||||
aggregatedSummary.lastLocationContent = ContentMapper.map(content.toContent())
|
aggregatedSummary.lastLocationContent = ContentMapper.map(content.toContent())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ internal interface LiveLocationAggregationProcessor {
|
||||||
event: Event,
|
event: Event,
|
||||||
content: MessageBeaconLocationDataContent,
|
content: MessageBeaconLocationDataContent,
|
||||||
roomId: String,
|
roomId: String,
|
||||||
|
relatedEventId: String?,
|
||||||
isLocalEcho: Boolean,
|
isLocalEcho: Boolean,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue