mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 12:05:22 +00:00
Fix naming confusion
This commit is contained in:
parent
193454beec
commit
c6976ca3cd
@ -67,7 +67,7 @@ object OpenGroupAPIV2 {
|
|||||||
|
|
||||||
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy::class)
|
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy::class)
|
||||||
data class MessageDeletion
|
data class MessageDeletion
|
||||||
@JvmOverloads constructor(val id: Long = 0, val deletedMessageId: Long = 0
|
@JvmOverloads constructor(val id: Long = 0, val deletedMessageServerID: Long = 0
|
||||||
) {
|
) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@ -396,13 +396,13 @@ object OpenGroupAPIV2 {
|
|||||||
// Deletions
|
// Deletions
|
||||||
val type = TypeFactory.defaultInstance().constructCollectionType(List::class.java, MessageDeletion::class.java)
|
val type = TypeFactory.defaultInstance().constructCollectionType(List::class.java, MessageDeletion::class.java)
|
||||||
val idsAsString = JsonUtil.toJson(json["deletions"])
|
val idsAsString = JsonUtil.toJson(json["deletions"])
|
||||||
val deletedServerIDs = JsonUtil.fromJson<List<MessageDeletion>>(idsAsString, type) ?: throw Error.ParsingFailed
|
val deletions = JsonUtil.fromJson<List<MessageDeletion>>(idsAsString, type) ?: throw Error.ParsingFailed
|
||||||
// Messages
|
// Messages
|
||||||
val rawMessages = json["messages"] as? List<Map<String, Any>> ?: return@mapNotNull null
|
val rawMessages = json["messages"] as? List<Map<String, Any>> ?: return@mapNotNull null
|
||||||
val messages = parseMessages(roomID, server, rawMessages)
|
val messages = parseMessages(roomID, server, rawMessages)
|
||||||
roomID to CompactPollResult(
|
roomID to CompactPollResult(
|
||||||
messages = messages,
|
messages = messages,
|
||||||
deletions = deletedServerIDs.map { it.deletedMessageId },
|
deletions = deletions,
|
||||||
moderators = moderators
|
moderators = moderators
|
||||||
)
|
)
|
||||||
}.toMap()
|
}.toMap()
|
||||||
|
@ -97,15 +97,15 @@ class OpenGroupPollerV2(private val server: String, private val executorService:
|
|||||||
JobQueue.shared.add(TrimThreadJob(threadId))
|
JobQueue.shared.add(TrimThreadJob(threadId))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleDeletedMessages(room: String, openGroupID: String, deletedMessageServerIDs: List<Long>) {
|
private fun handleDeletedMessages(room: String, openGroupID: String, deletions: List<OpenGroupAPIV2.MessageDeletion>) {
|
||||||
val storage = MessagingModuleConfiguration.shared.storage
|
val storage = MessagingModuleConfiguration.shared.storage
|
||||||
val dataProvider = MessagingModuleConfiguration.shared.messageDataProvider
|
val dataProvider = MessagingModuleConfiguration.shared.messageDataProvider
|
||||||
val groupID = GroupUtil.getEncodedOpenGroupID(openGroupID.toByteArray())
|
val groupID = GroupUtil.getEncodedOpenGroupID(openGroupID.toByteArray())
|
||||||
val threadID = storage.getThreadId(Address.fromSerialized(groupID)) ?: return
|
val threadID = storage.getThreadId(Address.fromSerialized(groupID)) ?: return
|
||||||
val deletedMessageIDs = deletedMessageServerIDs.mapNotNull { serverID ->
|
val deletedMessageIDs = deletions.mapNotNull { deletion ->
|
||||||
val messageID = dataProvider.getMessageID(serverID, threadID)
|
val messageID = dataProvider.getMessageID(deletion.deletedMessageServerID, threadID)
|
||||||
if (messageID == null) {
|
if (messageID == null) {
|
||||||
Log.d("Loki", "Couldn't find message ID for message with serverID: $serverID.")
|
Log.d("Loki", "Couldn't find message ID for message with serverID: ${deletion.deletedMessageServerID}.")
|
||||||
}
|
}
|
||||||
messageID
|
messageID
|
||||||
}
|
}
|
||||||
@ -113,7 +113,7 @@ class OpenGroupPollerV2(private val server: String, private val executorService:
|
|||||||
MessagingModuleConfiguration.shared.messageDataProvider.deleteMessage(messageId, isSms)
|
MessagingModuleConfiguration.shared.messageDataProvider.deleteMessage(messageId, isSms)
|
||||||
}
|
}
|
||||||
val currentMax = storage.getLastDeletionServerID(room, server) ?: 0L
|
val currentMax = storage.getLastDeletionServerID(room, server) ?: 0L
|
||||||
val latestMax = deletedMessageServerIDs.maxOrNull() ?: 0L
|
val latestMax = deletions.map { it.id }.maxOrNull() ?: 0L
|
||||||
if (latestMax > currentMax && latestMax != 0L) {
|
if (latestMax > currentMax && latestMax != 0L) {
|
||||||
storage.setLastDeletionServerID(room, server, latestMax)
|
storage.setLastDeletionServerID(room, server, latestMax)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user