Create processScannedLocationsForChat for scanned locations
This commit is contained in:
parent
8cb762cde2
commit
2dbb2b657e
2 changed files with 14 additions and 16 deletions
|
@ -91,8 +91,8 @@ class LocationMessages(val app: TelegramApplication) {
|
|||
val content = OsmandLocationUtils.parseMessageContent(message, app.telegramHelper)
|
||||
if (content != null) {
|
||||
val deviceName = if (content is OsmandLocationUtils.MessageOsmAndBotLocation) content.deviceName else ""
|
||||
val previousLocationMessage= lastLocationPoints.sortedBy { it.time }.firstOrNull {
|
||||
it.userId == senderId && it.chatId == message.chatId && it.type == type && it.deviceName == deviceName
|
||||
val previousLocationMessage = lastLocationPoints.sortedBy { it.time }.firstOrNull {
|
||||
it.userId == senderId && it.chatId == message.chatId && it.deviceName == deviceName && it.type == type
|
||||
}
|
||||
if (previousLocationMessage == null || content.lastUpdated * 1000L > previousLocationMessage.time) {
|
||||
log.debug("addNewLocationMessage passed ${message.id}")
|
||||
|
|
|
@ -605,29 +605,27 @@ class TelegramHelper private constructor() {
|
|||
log.debug("scanChatHistory searchMessageId: ${lastMessage.id}")
|
||||
} else {
|
||||
log.debug("scanChatHistory finishForChat: $chatId")
|
||||
if (locations.isNotEmpty()) {
|
||||
locations.sortBy { message -> OsmandLocationUtils.getLastUpdatedTime(message) }
|
||||
updateLastMessage(locations.last())
|
||||
incomingMessagesListeners.forEach {
|
||||
it.onReceiveChatLocationMessages(chatId, *locations.toTypedArray())
|
||||
}
|
||||
}
|
||||
processScannedLocationsForChat(chatId, locations)
|
||||
}
|
||||
} else {
|
||||
log.debug("scanChatHistory finishForChat: $chatId")
|
||||
if (locations.isNotEmpty()) {
|
||||
locations.sortBy { message -> OsmandLocationUtils.getLastUpdatedTime(message) }
|
||||
updateLastMessage(locations.last())
|
||||
incomingMessagesListeners.forEach {
|
||||
it.onReceiveChatLocationMessages(chatId, *locations.toTypedArray())
|
||||
}
|
||||
}
|
||||
processScannedLocationsForChat(chatId, locations)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun processScannedLocationsForChat(chatId: Long, locations: MutableList<TdApi.Message>) {
|
||||
if (locations.isNotEmpty()) {
|
||||
locations.sortBy { message -> OsmandLocationUtils.getLastUpdatedTime(message) }
|
||||
updateLastMessage(locations.last())
|
||||
incomingMessagesListeners.forEach {
|
||||
it.onReceiveChatLocationMessages(chatId, *locations.toTypedArray())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun requestUser(id: Int) {
|
||||
client?.send(TdApi.GetUser(id)) { obj ->
|
||||
when (obj.constructor) {
|
||||
|
|
Loading…
Reference in a new issue