feat: add basic message read logic for synchronizing last reads, need to modify the query to use the last seen instead of the unread count in a subquery possibly for thread display record

This commit is contained in:
0x330a
2023-02-15 17:29:29 +11:00
parent 03a343d832
commit 2f2ebe9451
14 changed files with 189 additions and 67 deletions

View File

@@ -2,6 +2,7 @@ package org.session.libsession.database
import android.content.Context
import android.net.Uri
import network.loki.messenger.libsession_util.ConfigBase
import org.session.libsession.messaging.BlindedIdMapping
import org.session.libsession.messaging.calls.CallMessageType
import org.session.libsession.messaging.contacts.Contact
@@ -31,6 +32,7 @@ import org.session.libsession.utilities.recipients.Recipient.RecipientSettings
import org.session.libsignal.crypto.ecc.ECKeyPair
import org.session.libsignal.messages.SignalServiceAttachmentPointer
import org.session.libsignal.messages.SignalServiceGroup
import network.loki.messenger.libsession_util.util.Contact as LibSessionContact
interface StorageProtocol {
@@ -164,6 +166,7 @@ interface StorageProtocol {
fun setContact(contact: Contact)
fun getRecipientForThread(threadId: Long): Recipient?
fun getRecipientSettings(address: Address): RecipientSettings?
fun addLibSessionContacts(contacts: List<LibSessionContact>)
fun addContacts(contacts: List<ConfigurationMessage.Contact>)
// Attachments
@@ -202,4 +205,7 @@ interface StorageProtocol {
fun deleteReactions(messageId: Long, mms: Boolean)
fun unblock(toUnblock: List<Recipient>)
fun blockedContacts(): List<Recipient>
// Shared configs
fun notifyConfigUpdates(forConfigObject: ConfigBase)
}

View File

@@ -161,7 +161,6 @@ class Poller(private val configFactory: ConfigFactoryProtocol) {
}
// process new results
configFactory.persist(forConfigObject)
configFactory.notifyUpdates(forConfigObject)
}
private fun poll(snode: Snode, deferred: Deferred<Unit, Exception>): Promise<Unit, Exception> {

View File

@@ -11,7 +11,10 @@ interface ConfigFactoryProtocol {
val convoVolatile: ConversationVolatileConfig?
fun persist(forConfigObject: ConfigBase)
fun appendHash(configObject: ConfigBase, hash: String)
fun notifyUpdates(forConfigObject: ConfigBase)
fun getHashesFor(forConfigObject: ConfigBase): List<String>
fun removeHashesFor(config: ConfigBase, deletedHashes: Set<String>): Boolean
}
interface ConfigFactoryUpdateListener {
fun notifyUpdates(forConfigObject: ConfigBase)
}

View File

@@ -3,7 +3,6 @@ package org.session.libsession.utilities
import org.session.libsignal.messages.SignalServiceGroup
import org.session.libsignal.utilities.Hex
import java.io.IOException
import kotlin.jvm.Throws
object GroupUtil {
const val CLOSED_GROUP_PREFIX = "__textsecure_group__!"
@@ -97,4 +96,10 @@ object GroupUtil {
fun doubleDecodeGroupID(groupID: String): ByteArray {
return getDecodedGroupIDAsData(getDecodedGroupID(groupID))
}
@JvmStatic
@Throws(IOException::class)
fun doubleDecodeGroupId(groupID: String): String {
return Hex.toStringCondensed(getDecodedGroupIDAsData(getDecodedGroupID(groupID)))
}
}