mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 17:27:45 +00:00
Merge branch 'fix-profile-picture-updating' of github.com:RyanRory/loki-messenger-android into dev
This commit is contained in:
commit
132ca11692
@ -194,6 +194,7 @@ class HomeActivity : PassphraseRequiredActionBarActivity, ConversationClickListe
|
|||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
|
profileButton.update()
|
||||||
val isMasterDevice = (TextSecurePreferences.getMasterHexEncodedPublicKey(this) == null)
|
val isMasterDevice = (TextSecurePreferences.getMasterHexEncodedPublicKey(this) == null)
|
||||||
val hasViewedSeed = TextSecurePreferences.getHasViewedSeed(this)
|
val hasViewedSeed = TextSecurePreferences.getHasViewedSeed(this)
|
||||||
if (hasViewedSeed || !isMasterDevice) {
|
if (hasViewedSeed || !isMasterDevice) {
|
||||||
|
@ -197,7 +197,7 @@ object MultiDeviceProtocol {
|
|||||||
TextSecurePreferences.setMultiDevice(context, true)
|
TextSecurePreferences.setMultiDevice(context, true)
|
||||||
LokiFileServerAPI.shared.addDeviceLink(deviceLink)
|
LokiFileServerAPI.shared.addDeviceLink(deviceLink)
|
||||||
org.thoughtcrime.securesms.loki.protocol.SessionMetaProtocol.handleProfileUpdateIfNeeded(context, content)
|
org.thoughtcrime.securesms.loki.protocol.SessionMetaProtocol.handleProfileUpdateIfNeeded(context, content)
|
||||||
org.thoughtcrime.securesms.loki.protocol.SessionMetaProtocol.handleProfileKeyUpdateIfNeeded(context, content)
|
org.thoughtcrime.securesms.loki.protocol.SessionMetaProtocol.handleProfileKey(context, content)
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
|
@ -4,11 +4,15 @@ import android.content.Context
|
|||||||
import org.thoughtcrime.securesms.ApplicationContext
|
import org.thoughtcrime.securesms.ApplicationContext
|
||||||
import org.thoughtcrime.securesms.database.Address
|
import org.thoughtcrime.securesms.database.Address
|
||||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||||
|
import org.thoughtcrime.securesms.database.RecipientDatabase
|
||||||
|
import org.thoughtcrime.securesms.jobs.RetrieveProfileAvatarJob
|
||||||
import org.thoughtcrime.securesms.recipients.Recipient
|
import org.thoughtcrime.securesms.recipients.Recipient
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||||
import org.whispersystems.signalservice.api.messages.SignalServiceContent
|
import org.whispersystems.signalservice.api.messages.SignalServiceContent
|
||||||
|
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage
|
||||||
import org.whispersystems.signalservice.loki.protocol.multidevice.MultiDeviceProtocol
|
import org.whispersystems.signalservice.loki.protocol.multidevice.MultiDeviceProtocol
|
||||||
import org.whispersystems.signalservice.loki.protocol.todo.LokiThreadFriendRequestStatus
|
import org.whispersystems.signalservice.loki.protocol.todo.LokiThreadFriendRequestStatus
|
||||||
|
import java.security.MessageDigest
|
||||||
|
|
||||||
object SessionMetaProtocol {
|
object SessionMetaProtocol {
|
||||||
|
|
||||||
@ -39,6 +43,28 @@ object SessionMetaProtocol {
|
|||||||
if (!allUserDevices.contains(sender)) {
|
if (!allUserDevices.contains(sender)) {
|
||||||
val displayName = rawDisplayName + " (..." + sender.substring(sender.length - 8) + ")"
|
val displayName = rawDisplayName + " (..." + sender.substring(sender.length - 8) + ")"
|
||||||
DatabaseFactory.getLokiUserDatabase(context).setDisplayName(sender, displayName)
|
DatabaseFactory.getLokiUserDatabase(context).setDisplayName(sender, displayName)
|
||||||
|
} else {
|
||||||
|
DatabaseFactory.getLokiUserDatabase(context).setDisplayName(sender, rawDisplayName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun handleProfileKey(context: Context, content: SignalServiceContent) {
|
||||||
|
val message = content.dataMessage.get()
|
||||||
|
if (!message.profileKey.isPresent) { return }
|
||||||
|
|
||||||
|
/*
|
||||||
|
If we get a profile key then we don't need to map it to the primary device.
|
||||||
|
For now a profile key is mapped one-to-one to avoid secondary devices setting the incorrect avatar for a primary device.
|
||||||
|
*/
|
||||||
|
val database = DatabaseFactory.getRecipientDatabase(context)
|
||||||
|
val recipient = Recipient.from(context, Address.fromSerialized(content.sender), false)
|
||||||
|
if (recipient.profileKey == null || !MessageDigest.isEqual(recipient.profileKey, message.profileKey.get())) {
|
||||||
|
database.setProfileKey(recipient, message.profileKey.get())
|
||||||
|
database.setUnidentifiedAccessMode(recipient, RecipientDatabase.UnidentifiedAccessMode.UNKNOWN)
|
||||||
|
val url = content.senderProfilePictureURL.or("")
|
||||||
|
ApplicationContext.getInstance(context).jobManager.add(RetrieveProfileAvatarJob(recipient, url))
|
||||||
|
handleProfileKeyUpdateIfNeeded(context, content)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user