fix: force has sent for local user, only prevent setting last seen for open group recipients, allow empty user pics to trigger config sync in settings

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

View File

@ -248,6 +248,10 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
// assume created thread
if (recipient.isContactRecipient && !recipient.isLocalNumber) {
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()

View File

@ -182,8 +182,9 @@ open class Storage(context: Context, helper: SQLCipherOpenHelper, private val co
val ourRecipient = fromSerialized(getUserPublicKey()!!).let {
Recipient.from(context, it, false)
}
TextSecurePreferences.setProfilePictureURL(context, newProfilePicture)
ourRecipient.resolve().profileKey = newProfileKey
TextSecurePreferences.setProfileKey(context, newProfileKey?.let { Base64.encodeBytes(it) })
TextSecurePreferences.setProfilePictureURL(context, newProfilePicture)
ApplicationContext.getInstance(context).jobManager.add(RetrieveProfileAvatarJob(ourRecipient, newProfilePicture))
}
@ -437,6 +438,7 @@ open class Storage(context: Context, helper: SQLCipherOpenHelper, private val co
} else {
// create note to self thread if needed (?)
val ourThread = getOrCreateThreadIdFor(recipient.address)
DatabaseComponent.get(context).threadDatabase().setHasSent(ourThread, true)
setPinned(ourThread, userProfile.getNtsPriority() > 0)
}
@ -1008,7 +1010,10 @@ open class Storage(context: Context, helper: SQLCipherOpenHelper, private val co
val communityInfo = groups.getOrConstructCommunityInfo(infoServer, infoRoom, pubKeyHex)
groups.set(communityInfo)
val volatile = volatileConfig.getOrConstructCommunity(infoServer, infoRoom, pubKey)
volatileConfig.set(volatile.copy(lastRead = 0))
if (volatile.lastRead != 0L) {
val threadId = getThreadId(openGroup) ?: return
markConversationAsRead(threadId, volatile.lastRead)
}
}
override fun hasBackgroundGroupAddJob(groupJoinUrl: String): Boolean {

View File

@ -539,7 +539,8 @@ public class ThreadDatabase extends Database {
public boolean setLastSeen(long threadId, long timestamp) {
// edge case where we set the last seen time for a conversation before it loads messages (joining community for example)
MmsSmsDatabase mmsSmsDatabase = DatabaseComponent.get(context).mmsSmsDatabase();
if (mmsSmsDatabase.getConversationCount(threadId) <= 0) return false;
Recipient forThreadId = getRecipientForThreadId(threadId);
if (mmsSmsDatabase.getConversationCount(threadId) <= 0 && forThreadId != null && forThreadId.isOpenGroupRecipient()) return false;
SQLiteDatabase db = databaseHelper.getWritableDatabase();

View File

@ -2,7 +2,10 @@ package org.thoughtcrime.securesms.preferences
import android.Manifest
import android.app.Activity
import android.content.*
import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.AsyncTask
import android.os.Bundle
@ -232,16 +235,16 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() {
// new config
val url = TextSecurePreferences.getProfilePictureURL(this)
val profileKey = ProfileKeyUtil.getProfileKey(this)
if (!url.isNullOrEmpty() && profileKey.isNotEmpty()) {
if (profilePicture == null) {
userConfig?.setPic(UserPic.DEFAULT)
} else if (!url.isNullOrEmpty() && profileKey.isNotEmpty()) {
userConfig?.setPic(UserPic(url, profileKey))
}
}
if (profilePicture != null || displayName != null) {
if (userConfig != null && userConfig.needsDump()) {
configFactory.persist(userConfig)
}
ConfigurationMessageUtilities.forceSyncConfigurationNowIfNeeded(this@SettingsActivity)
if (userConfig != null && userConfig.needsDump()) {
configFactory.persist(userConfig)
}
ConfigurationMessageUtilities.forceSyncConfigurationNowIfNeeded(this@SettingsActivity)
}
compoundPromise.alwaysUi {
if (displayName != null) {