fix: nts threads

This commit is contained in:
0x330a 2023-05-23 14:56:37 +10:00
parent 4f534d5a1e
commit f91fc2503b
No known key found for this signature in database
GPG Key ID: 267811D6E6A2698C
4 changed files with 15 additions and 6 deletions

View File

@ -248,10 +248,6 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
// assume created thread // assume created thread
if (recipient.isContactRecipient && !recipient.isLocalNumber) { if (recipient.isContactRecipient && !recipient.isLocalNumber) {
storage.setRecipientApproved(recipient, true) // assume approved when we CREATE the thread, not send first message storage.setRecipientApproved(recipient, true) // assume approved when we CREATE the thread, not send first message
} else if (recipient.isLocalNumber) {
// this gets around the filtering of unapproved / unsent threads
// since the sql query would have to take into account whether address == local user address
threadDb.setHasSent(threadId, true)
} }
} }
} ?: finish() } ?: finish()

View File

@ -5,6 +5,7 @@ import android.net.Uri
import network.loki.messenger.libsession_util.ConfigBase import network.loki.messenger.libsession_util.ConfigBase
import network.loki.messenger.libsession_util.ConfigBase.Companion.PRIORITY_HIDDEN import network.loki.messenger.libsession_util.ConfigBase.Companion.PRIORITY_HIDDEN
import network.loki.messenger.libsession_util.ConfigBase.Companion.PRIORITY_PINNED import network.loki.messenger.libsession_util.ConfigBase.Companion.PRIORITY_PINNED
import network.loki.messenger.libsession_util.ConfigBase.Companion.PRIORITY_VISIBLE
import network.loki.messenger.libsession_util.Contacts import network.loki.messenger.libsession_util.Contacts
import network.loki.messenger.libsession_util.ConversationVolatileConfig import network.loki.messenger.libsession_util.ConversationVolatileConfig
import network.loki.messenger.libsession_util.UserGroupsConfig import network.loki.messenger.libsession_util.UserGroupsConfig
@ -95,7 +96,18 @@ open class Storage(context: Context, helper: SQLCipherOpenHelper, private val co
ThreadDatabase.ConversationThreadUpdateListener { ThreadDatabase.ConversationThreadUpdateListener {
override fun threadCreated(address: Address, threadId: Long) { override fun threadCreated(address: Address, threadId: Long) {
if (!getRecipientApproved(address)) return // don't store unapproved / message requests val localUserAddress = getUserPublicKey() ?: return
if (!getRecipientApproved(address) && localUserAddress != address.serialize()) return // don't store unapproved / message requests
if (localUserAddress == address.serialize()) {
val userConfig = configFactory.user ?: return
if (userConfig.getNtsPriority() == PRIORITY_HIDDEN) {
// if it's hidden set it visible, otherwise it's pinned so don't change
userConfig.setNtsPriority(PRIORITY_VISIBLE)
DatabaseComponent.get(context).threadDatabase().setHasSent(threadId, true)
}
return
}
val volatile = configFactory.convoVolatile ?: return val volatile = configFactory.convoVolatile ?: return
if (address.isGroup) { if (address.isGroup) {

View File

@ -728,6 +728,7 @@ public class ThreadDatabase extends Database {
new String[] {String.valueOf(threadId)}); new String[] {String.valueOf(threadId)});
notifyConversationListeners(threadId); notifyConversationListeners(threadId);
notifyConversationListListeners();
} }
public boolean update(long threadId, boolean unarchive, boolean shouldDeleteOnEmpty) { public boolean update(long threadId, boolean unarchive, boolean shouldDeleteOnEmpty) {

View File

@ -1,6 +1,6 @@
android.useAndroidX=true android.useAndroidX=true
android.enableJetifier=true android.enableJetifier=true
org.gradle.jvmargs=-Xmx8g org.gradle.jvmargs=-Xmx4g
gradlePluginVersion=7.3.1 gradlePluginVersion=7.3.1
googleServicesVersion=4.3.12 googleServicesVersion=4.3.12