mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-23 18:15:22 +00:00
Merge branch 'dev' of https://github.com/oxen-io/session-android into ONS-name-1
This commit is contained in:
commit
a81c17057f
@ -143,8 +143,8 @@ dependencies {
|
||||
testImplementation 'org.robolectric:shadows-multidex:4.2'
|
||||
}
|
||||
|
||||
def canonicalVersionCode = 177
|
||||
def canonicalVersionName = "1.10.9"
|
||||
def canonicalVersionCode = 178
|
||||
def canonicalVersionName = "1.10.10"
|
||||
|
||||
def postFixSize = 10
|
||||
def abiPostFix = ['armeabi-v7a' : 1,
|
||||
|
@ -17,14 +17,9 @@ import org.session.libsession.messaging.sending_receiving.pollers.OpenGroupPolle
|
||||
import org.session.libsession.snode.OnionRequestAPI
|
||||
import org.session.libsession.utilities.AESGCM
|
||||
import org.session.libsession.utilities.TextSecurePreferences
|
||||
import org.session.libsignal.utilities.HTTP
|
||||
import org.session.libsignal.utilities.HTTP.Verb.*
|
||||
import org.session.libsignal.utilities.removing05PrefixIfNeeded
|
||||
import org.session.libsignal.utilities.toHexString
|
||||
import org.session.libsignal.utilities.*
|
||||
import org.session.libsignal.utilities.Base64.*
|
||||
import org.session.libsignal.utilities.Hex
|
||||
import org.session.libsignal.utilities.JsonUtil
|
||||
import org.session.libsignal.utilities.Log
|
||||
import org.session.libsignal.utilities.HTTP.Verb.*
|
||||
import org.whispersystems.curve25519.Curve25519
|
||||
import java.util.*
|
||||
|
||||
@ -63,11 +58,11 @@ object OpenGroupAPIV2 {
|
||||
|
||||
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy::class)
|
||||
data class CompactPollRequest(val roomID: String, val authToken: String, val fromDeletionServerID: Long?, val fromMessageServerID: Long?)
|
||||
data class CompactPollResult(val messages: List<OpenGroupMessageV2>, val deletions: List<Long>, val moderators: List<String>)
|
||||
data class CompactPollResult(val messages: List<OpenGroupMessageV2>, val deletions: List<MessageDeletion>, val moderators: List<String>)
|
||||
|
||||
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy::class)
|
||||
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 {
|
||||
@ -396,13 +391,13 @@ object OpenGroupAPIV2 {
|
||||
// Deletions
|
||||
val type = TypeFactory.defaultInstance().constructCollectionType(List::class.java, MessageDeletion::class.java)
|
||||
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
|
||||
val rawMessages = json["messages"] as? List<Map<String, Any>> ?: return@mapNotNull null
|
||||
val messages = parseMessages(roomID, server, rawMessages)
|
||||
roomID to CompactPollResult(
|
||||
messages = messages,
|
||||
deletions = deletedServerIDs.map { it.deletedMessageId },
|
||||
deletions = deletions,
|
||||
moderators = moderators
|
||||
)
|
||||
}.toMap()
|
||||
|
@ -97,15 +97,15 @@ class OpenGroupPollerV2(private val server: String, private val executorService:
|
||||
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 dataProvider = MessagingModuleConfiguration.shared.messageDataProvider
|
||||
val groupID = GroupUtil.getEncodedOpenGroupID(openGroupID.toByteArray())
|
||||
val threadID = storage.getThreadId(Address.fromSerialized(groupID)) ?: return
|
||||
val deletedMessageIDs = deletedMessageServerIDs.mapNotNull { serverID ->
|
||||
val messageID = dataProvider.getMessageID(serverID, threadID)
|
||||
val deletedMessageIDs = deletions.mapNotNull { deletion ->
|
||||
val messageID = dataProvider.getMessageID(deletion.deletedMessageServerID, threadID)
|
||||
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
|
||||
}
|
||||
@ -113,7 +113,7 @@ class OpenGroupPollerV2(private val server: String, private val executorService:
|
||||
MessagingModuleConfiguration.shared.messageDataProvider.deleteMessage(messageId, isSms)
|
||||
}
|
||||
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) {
|
||||
storage.setLastDeletionServerID(room, server, latestMax)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user